Changeset 205325 in webkit
- Timestamp:
- Sep 1, 2016 3:45:52 PM (8 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r205313 r205325 1 2016-09-01 Anders Carlsson <andersca@apple.com> 2 3 Use BlockPtr::fromCallable in WorkQueue::dispatch and WorkQueue::dispatchAfter 4 https://bugs.webkit.org/show_bug.cgi?id=161512 5 6 Reviewed by Chris Dumez. 7 8 This lets us get rid of leakCallable and adoptCallable. 9 10 * wtf/BlockPtr.h: 11 * wtf/Function.h: 12 * wtf/cocoa/WorkQueueCocoa.cpp: 13 (WTF::WorkQueue::dispatch): 14 (WTF::WorkQueue::dispatchAfter): 15 1 16 2016-09-01 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/Source/WTF/wtf/BlockPtr.h
r205313 r205325 91 91 92 92 BlockPtr blockPtr; 93 blockPtr.m_block = static_cast<BlockType>(block);93 blockPtr.m_block = reinterpret_cast<BlockType>(block); 94 94 95 95 return blockPtr; -
trunk/Source/WTF/wtf/Function.h
r203236 r205325 67 67 } 68 68 69 private: 69 70 class CallableWrapperBase { 70 71 WTF_MAKE_FAST_ALLOCATED; … … 75 76 }; 76 77 77 CallableWrapperBase* leakCallable() WARN_UNUSED_RETURN78 {79 return m_callableWrapper.release();80 }81 82 static Function adoptCallable(CallableWrapperBase* callable)83 {84 Function function;85 function.m_callableWrapper.reset(callable);86 return function;87 }88 89 private:90 78 template<typename CallableType> 91 79 class CallableWrapper : public CallableWrapperBase { -
trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
r203236 r205325 26 26 #include "config.h" 27 27 #include "WorkQueue.h" 28 #include "BlockPtr.h" 29 #include "Ref.h" 28 30 29 31 namespace WTF { … … 31 33 void WorkQueue::dispatch(Function<void ()>&& function) 32 34 { 33 ref(); 34 auto* callable = function.leakCallable(); 35 dispatch_async(m_dispatchQueue, ^{ 36 auto function = Function<void ()>::adoptCallable(callable); 35 dispatch_async(m_dispatchQueue, BlockPtr<void ()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] { 37 36 function(); 38 deref(); 39 }); 37 }).get()); 40 38 } 41 39 42 40 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, Function<void ()>&& function) 43 41 { 44 ref(); 45 auto* callable = function.leakCallable(); 46 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, ^{ 47 auto function = Function<void ()>::adoptCallable(callable); 42 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, BlockPtr<void ()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] { 48 43 function(); 49 deref(); 50 }); 44 }).get()); 51 45 } 52 46
Note: See TracChangeset
for help on using the changeset viewer.