Changeset 157374 in webkit
- Timestamp:
- Oct 13, 2013 9:12:49 AM (11 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r157341 r157374 1 2013-10-12 Anders Carlsson <andersca@apple.com> 2 3 Change callOnMainThread to take an std::function 4 https://bugs.webkit.org/show_bug.cgi?id=122698 5 6 Reviewed by Darin Adler. 7 8 This will let us pass anything that can be converted to an std::function (including lambdas and 9 WTF::Function objects) to callOnMainThread. 10 11 * wtf/MainThread.cpp: 12 (WTF::callOnMainThread): 13 * wtf/MainThread.h: 14 1 15 2013-09-06 Jessica Pease <jessica_n_pease@apple.com> 2 16 -
trunk/Source/WTF/wtf/MainThread.cpp
r155926 r157374 233 233 static void callFunctionObject(void* context) 234 234 { 235 Function<void ()>* function = static_cast<Function<void ()>*>(context);235 auto function = std::unique_ptr<std::function<void ()>>(static_cast<std::function<void ()>*>(context)); 236 236 (*function)(); 237 delete function; 238 } 239 240 void callOnMainThread(const Function<void ()>& function) 241 { 242 callOnMainThread(callFunctionObject, new Function<void ()>(function)); 237 } 238 239 void callOnMainThread(std::function<void ()> function) 240 { 241 callOnMainThread(callFunctionObject, std::make_unique<std::function<void ()>>(std::move(function)).release()); 243 242 } 244 243 -
trunk/Source/WTF/wtf/MainThread.h
r156127 r157374 31 31 #define MainThread_h 32 32 33 #include <functional> 33 34 #include <stdint.h> 34 35 … … 45 46 WTF_EXPORT_PRIVATE void cancelCallOnMainThread(MainThreadFunction*, void* context); 46 47 47 template<typename> class Function; 48 WTF_EXPORT_PRIVATE void callOnMainThread(const Function<void ()>&); 49 48 WTF_EXPORT_PRIVATE void callOnMainThread(std::function<void ()>); 49 50 50 WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused); 51 51
Note: See TracChangeset
for help on using the changeset viewer.