Changeset 201683 in webkit
- Timestamp:
- Jun 4, 2016 12:26:24 PM (8 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r201673 r201683 1 2016-06-03 Anders Carlsson <andersca@apple.com> 2 3 Get rid of HANDLE registration code in WorkQueueWin 4 https://bugs.webkit.org/show_bug.cgi?id=158375 5 6 Reviewed by Darin Adler. 7 8 * wtf/WorkQueue.h: 9 * wtf/win/WorkItemWin.cpp: 10 (WTF::HandleWorkItem::HandleWorkItem): Deleted. 11 (WTF::HandleWorkItem::createByAdoptingHandle): Deleted. 12 (WTF::HandleWorkItem::~HandleWorkItem): Deleted. 13 * wtf/win/WorkItemWin.h: 14 (WTF::HandleWorkItem::setWaitHandle): Deleted. 15 (WTF::HandleWorkItem::waitHandle): Deleted. 16 * wtf/win/WorkQueueWin.cpp: 17 (WTF::WorkQueue::handleCallback): Deleted. 18 (WTF::WorkQueue::platformInvalidate): Deleted. 19 (WTF::WorkQueue::unregisterWaitAndDestroyItemSoon): Deleted. 20 (WTF::WorkQueue::unregisterWaitAndDestroyItemCallback): Deleted. 21 1 22 2016-06-03 Commit Queue <commit-queue@webkit.org> 2 23 -
trunk/Source/WTF/wtf/WorkQueue.h
r201673 r201683 94 94 95 95 #if USE(WINDOWS_EVENT_LOOP) 96 static void CALLBACK handleCallback(void* context, BOOLEAN timerOrWaitFired);97 96 static void CALLBACK timerCallback(void* context, BOOLEAN timerOrWaitFired); 98 97 static DWORD WINAPI workThreadCallback(void* context); … … 101 100 void unregisterAsWorkThread(); 102 101 void performWorkOnRegisteredWorkThread(); 103 104 static void unregisterWaitAndDestroyItemSoon(PassRefPtr<HandleWorkItem>);105 static DWORD WINAPI unregisterWaitAndDestroyItemCallback(void* context);106 102 #endif 107 103 … … 116 112 Mutex m_workItemQueueLock; 117 113 Vector<RefPtr<WorkItemWin>> m_workItemQueue; 118 119 Mutex m_handlesLock;120 HashMap<HANDLE, RefPtr<HandleWorkItem>> m_handles;121 114 122 115 HANDLE m_timerQueue; -
trunk/Source/WTF/wtf/win/WorkItemWin.cpp
r201673 r201683 48 48 } 49 49 50 HandleWorkItem::HandleWorkItem(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue)51 : WorkItemWin(WTFMove(function), queue)52 , m_handle(handle)53 , m_waitHandle(0)54 {55 ASSERT_ARG(handle, handle);56 }57 58 RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue)59 {60 return adoptRef(new HandleWorkItem(handle, WTFMove(function), queue));61 }62 63 HandleWorkItem::~HandleWorkItem()64 {65 ::CloseHandle(m_handle);66 }67 68 50 } // namespace WTF -
trunk/Source/WTF/wtf/win/WorkItemWin.h
r201673 r201683 54 54 }; 55 55 56 class HandleWorkItem : public WorkItemWin {57 public:58 static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*);59 virtual ~HandleWorkItem();60 61 void setWaitHandle(HANDLE waitHandle) { m_waitHandle = waitHandle; }62 HANDLE waitHandle() const { return m_waitHandle; }63 64 private:65 HandleWorkItem(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*);66 67 HANDLE m_handle;68 HANDLE m_waitHandle;69 };70 71 56 } 72 57 -
trunk/Source/WTF/wtf/win/WorkQueueWin.cpp
r201673 r201683 32 32 33 33 namespace WTF { 34 35 void WorkQueue::handleCallback(void* context, BOOLEAN timerOrWaitFired)36 {37 ASSERT_ARG(context, context);38 ASSERT_ARG(timerOrWaitFired, !timerOrWaitFired);39 40 WorkItemWin* item = static_cast<WorkItemWin*>(context);41 RefPtr<WorkQueue> queue = item->queue();42 43 {44 MutexLocker lock(queue->m_workItemQueueLock);45 queue->m_workItemQueue.append(item);46 47 // If no other thread is performing work, we can do it on this thread.48 if (!queue->tryRegisterAsWorkThread()) {49 // Some other thread is performing work. Since we hold the queue lock, we can be sure50 // that the work thread is not exiting due to an empty queue and will process the work51 // item we just added to it. If we weren't holding the lock we'd have to signal52 // m_performWorkEvent to make sure the work item got picked up.53 return;54 }55 }56 57 queue->performWorkOnRegisteredWorkThread();58 }59 34 60 35 DWORD WorkQueue::workThreadCallback(void* context) … … 120 95 void WorkQueue::platformInvalidate() 121 96 { 122 #if !ASSERT_DISABLED123 MutexLocker lock(m_handlesLock);124 ASSERT(m_handles.isEmpty());125 #endif126 127 97 // FIXME: We need to ensure that any timer-queue timers that fire after this point don't try to 128 98 // access this WorkQueue <http://webkit.org/b/44690>. … … 222 192 } 223 193 224 void WorkQueue::unregisterWaitAndDestroyItemSoon(PassRefPtr<HandleWorkItem> item)225 {226 // We're going to make a blocking call to ::UnregisterWaitEx before closing the handle. (The227 // blocking version of ::UnregisterWaitEx is much simpler than the non-blocking version.) If we228 // do this on the current thread, we'll deadlock if we're currently in a callback function for229 // the wait we're unregistering. So instead we do it asynchronously on some other worker thread.230 231 ::QueueUserWorkItem(unregisterWaitAndDestroyItemCallback, item.leakRef(), WT_EXECUTEDEFAULT);232 }233 234 DWORD WINAPI WorkQueue::unregisterWaitAndDestroyItemCallback(void* context)235 {236 ASSERT_ARG(context, context);237 RefPtr<HandleWorkItem> item = adoptRef(static_cast<HandleWorkItem*>(context));238 239 // Now that we know we're not in a callback function for the wait we're unregistering, we can240 // make a blocking call to ::UnregisterWaitEx.241 if (!::UnregisterWaitEx(item->waitHandle(), INVALID_HANDLE_VALUE)) {242 DWORD error = ::GetLastError();243 ASSERT_NOT_REACHED();244 }245 246 return 0;247 }248 249 194 } // namespace WTF
Note: See TracChangeset
for help on using the changeset viewer.