Changeset 102866 in webkit
- Timestamp:
- Dec 14, 2011 6:10:51 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r102849 r102866 1 2011-12-14 Anders Carlsson <andersca@apple.com> 2 3 Add WorkQueue::dispatch and RunLoop::dispatch which both take WTF::Function objects 4 https://bugs.webkit.org/show_bug.cgi?id=74574 5 6 Reviewed by Sam Weinig. 7 8 * Platform/CoreIPC/Connection.cpp: 9 (CoreIPC::Connection::SyncMessageState::processIncomingMessage): 10 (CoreIPC::Connection::addQueueClient): 11 (CoreIPC::Connection::removeQueueClient): 12 (CoreIPC::Connection::invalidate): 13 (CoreIPC::Connection::sendMessage): 14 (CoreIPC::Connection::postConnectionDidCloseOnConnectionWorkQueue): 15 (CoreIPC::Connection::connectionDidClose): 16 (CoreIPC::Connection::enqueueIncomingMessage): 17 Switch over to dispatch. 18 19 * Platform/RunLoop.cpp: 20 (RunLoop::dispatch): 21 Create a FunctionWorkItem and call scheduleWork. 22 23 * Platform/RunLoop.h: 24 Add dispatch. 25 26 * Platform/WorkItem.h: 27 (FunctionWorkItem::FunctionWorkItem): 28 (FunctionWorkItem::execute): 29 (WorkItem::create): 30 Add a helper work item that wraps a WTF::Function. 31 32 * Platform/WorkQueue.cpp: 33 (WorkQueue::dispatch): 34 Create a FunctionWorkItem and call scheduleWork. 35 36 * Platform/WorkQueue.h: 37 Add dispatch. 38 39 * UIProcess/Launcher/ProcessLauncher.cpp: 40 (WebKit::ProcessLauncher::ProcessLauncher): 41 Switch over to dispatch. 42 1 43 2011-12-14 Hajime Morrita <morrita@chromium.org> 2 44 -
trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp
r102615 r102866 142 142 143 143 if (!m_didScheduleDispatchMessagesWork) { 144 m_runLoop-> scheduleWork(WorkItem::create(this, &SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesWork));144 m_runLoop->dispatch(bind(&SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesWork, this)); 145 145 m_didScheduleDispatchMessagesWork = true; 146 146 } … … 237 237 void Connection::addQueueClient(QueueClient* queueClient) 238 238 { 239 m_connectionQueue. scheduleWork(WorkItem::create(this, &Connection::addQueueClientOnWorkQueue, queueClient));239 m_connectionQueue.dispatch(bind(&Connection::addQueueClientOnWorkQueue, this, queueClient)); 240 240 } 241 241 242 242 void Connection::removeQueueClient(QueueClient* queueClient) 243 243 { 244 m_connectionQueue. scheduleWork(WorkItem::create(this, &Connection::removeQueueClientOnWorkQueue, queueClient));244 m_connectionQueue.dispatch(bind(&Connection::removeQueueClientOnWorkQueue, this, queueClient)); 245 245 } 246 246 … … 275 275 m_client = 0; 276 276 277 m_connectionQueue. scheduleWork(WorkItem::create(this, &Connection::platformInvalidate));277 m_connectionQueue.dispatch(bind(&Connection::platformInvalidate, this)); 278 278 } 279 279 … … 318 318 319 319 // FIXME: We should add a boolean flag so we don't call this when work has already been scheduled. 320 m_connectionQueue. scheduleWork(WorkItem::create(this, &Connection::sendOutgoingMessages));320 m_connectionQueue.dispatch(bind(&Connection::sendOutgoingMessages, this)); 321 321 return true; 322 322 } … … 566 566 void Connection::postConnectionDidCloseOnConnectionWorkQueue() 567 567 { 568 m_connectionQueue. scheduleWork(WorkItem::create(this, &Connection::connectionDidClose));568 m_connectionQueue.dispatch(bind(&Connection::connectionDidClose, this)); 569 569 } 570 570 … … 587 587 m_didCloseOnConnectionWorkQueueCallback(m_connectionQueue, this); 588 588 589 m_clientRunLoop-> scheduleWork(WorkItem::create(this, &Connection::dispatchConnectionDidClose));589 m_clientRunLoop->dispatch(bind(&Connection::dispatchConnectionDidClose, this)); 590 590 } 591 591 … … 667 667 m_incomingMessages.append(incomingMessage); 668 668 669 m_clientRunLoop-> scheduleWork(WorkItem::create(this, &Connection::dispatchMessages));669 m_clientRunLoop->dispatch(bind(&Connection::dispatchMessages, this)); 670 670 } 671 671 -
trunk/Source/WebKit2/Platform/RunLoop.cpp
r95901 r102866 65 65 } 66 66 67 void RunLoop::dispatch(const Function<void()>& function) 68 { 69 scheduleWork(WorkItem::create(function)); 70 } 71 67 72 void RunLoop::scheduleWork(PassOwnPtr<WorkItem> item) 68 73 { -
trunk/Source/WebKit2/Platform/RunLoop.h
r95901 r102866 48 48 } 49 49 50 namespace WTF { 51 template<typename> class Function; 52 } 53 using WTF::Function; 54 50 55 class RunLoop { 51 56 public: … … 56 61 static RunLoop* main(); 57 62 63 // FIXME: Get rid of this overload and use WTF::Function everywhere. 58 64 void scheduleWork(PassOwnPtr<WorkItem>); 65 66 void dispatch(const Function<void()>&); 59 67 60 68 #if PLATFORM(WIN) -
trunk/Source/WebKit2/Platform/WorkItem.h
r95901 r102866 27 27 #define WorkItem_h 28 28 29 #include <wtf/Functional.h> 29 30 #include <wtf/PassOwnPtr.h> 30 31 … … 45 46 static PassOwnPtr<WorkItem> createDeref(C*); 46 47 48 static PassOwnPtr<WorkItem> create(const Function<void()>&); 49 47 50 virtual ~WorkItem() { } 48 51 virtual void execute() = 0; … … 212 215 } 213 216 217 // FunctionWorkItem is a temporary class. WorkItem should just be replaced by WTF::Function everywhere. 218 class FunctionWorkItem : private WorkItem { 219 // We only allow WorkItem to create this. 220 friend class WorkItem; 221 222 explicit FunctionWorkItem(const Function<void()>& function) 223 : m_function(function) 224 { 225 } 226 227 virtual void execute() 228 { 229 m_function(); 230 } 231 232 Function<void()> m_function; 233 }; 234 235 inline PassOwnPtr<WorkItem> WorkItem::create(const Function<void()>& function) 236 { 237 return adoptPtr(static_cast<WorkItem*>(new FunctionWorkItem(function))); 238 } 239 214 240 #endif // WorkItem_h -
trunk/Source/WebKit2/Platform/WorkQueue.cpp
r95901 r102866 41 41 } 42 42 43 void WorkQueue::dispatch(const Function<void()>& function) 44 { 45 scheduleWork(WorkItem::create(function)); 46 } 47 43 48 void WorkQueue::invalidate() 44 49 { -
trunk/Source/WebKit2/Platform/WorkQueue.h
r101141 r102866 53 53 #endif 54 54 55 namespace WTF { 56 template<typename> class Function; 57 } 58 using WTF::Function; 59 55 60 class WorkQueue { 56 61 WTF_MAKE_NONCOPYABLE(WorkQueue); … … 59 64 explicit WorkQueue(const char* name); 60 65 ~WorkQueue(); 66 67 // Will dispatch the given function to run as soon as possible. 68 void dispatch(const Function<void()>&); 69 70 // FIXME: Get rid of WorkItem everywhere. 61 71 62 72 // Will schedule the given work item to run as soon as possible. -
trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
r95901 r102866 45 45 // Launch the process. 46 46 m_isLaunching = true; 47 processLauncherWorkQueue(). scheduleWork(WorkItem::create(this, &ProcessLauncher::launchProcess));47 processLauncherWorkQueue().dispatch(bind(&ProcessLauncher::launchProcess, this)); 48 48 } 49 49
Note: See TracChangeset
for help on using the changeset viewer.