Changeset 201683 in webkit


Ignore:
Timestamp:
Jun 4, 2016 12:26:24 PM (8 years ago)
Author:
andersca@apple.com
Message:

Get rid of HANDLE registration code in WorkQueueWin
https://bugs.webkit.org/show_bug.cgi?id=158375

Reviewed by Darin Adler.

  • wtf/WorkQueue.h:
  • wtf/win/WorkItemWin.cpp:

(WTF::HandleWorkItem::HandleWorkItem): Deleted.
(WTF::HandleWorkItem::createByAdoptingHandle): Deleted.
(WTF::HandleWorkItem::~HandleWorkItem): Deleted.

  • wtf/win/WorkItemWin.h:

(WTF::HandleWorkItem::setWaitHandle): Deleted.
(WTF::HandleWorkItem::waitHandle): Deleted.

  • wtf/win/WorkQueueWin.cpp:

(WTF::WorkQueue::handleCallback): Deleted.
(WTF::WorkQueue::platformInvalidate): Deleted.
(WTF::WorkQueue::unregisterWaitAndDestroyItemSoon): Deleted.
(WTF::WorkQueue::unregisterWaitAndDestroyItemCallback): Deleted.

Location:
trunk/Source/WTF
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r201673 r201683  
     12016-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
    1222016-06-03  Commit Queue  <commit-queue@webkit.org>
    223
  • trunk/Source/WTF/wtf/WorkQueue.h

    r201673 r201683  
    9494
    9595#if USE(WINDOWS_EVENT_LOOP)
    96     static void CALLBACK handleCallback(void* context, BOOLEAN timerOrWaitFired);
    9796    static void CALLBACK timerCallback(void* context, BOOLEAN timerOrWaitFired);
    9897    static DWORD WINAPI workThreadCallback(void* context);
     
    101100    void unregisterAsWorkThread();
    102101    void performWorkOnRegisteredWorkThread();
    103 
    104     static void unregisterWaitAndDestroyItemSoon(PassRefPtr<HandleWorkItem>);
    105     static DWORD WINAPI unregisterWaitAndDestroyItemCallback(void* context);
    106102#endif
    107103
     
    116112    Mutex m_workItemQueueLock;
    117113    Vector<RefPtr<WorkItemWin>> m_workItemQueue;
    118 
    119     Mutex m_handlesLock;
    120     HashMap<HANDLE, RefPtr<HandleWorkItem>> m_handles;
    121114
    122115    HANDLE m_timerQueue;
  • trunk/Source/WTF/wtf/win/WorkItemWin.cpp

    r201673 r201683  
    4848}
    4949
    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 
    6850} // namespace WTF
  • trunk/Source/WTF/wtf/win/WorkItemWin.h

    r201673 r201683  
    5454};
    5555
    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 
    7156}
    7257
  • trunk/Source/WTF/wtf/win/WorkQueueWin.cpp

    r201673 r201683  
    3232
    3333namespace 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 sure
    50             // that the work thread is not exiting due to an empty queue and will process the work
    51             // item we just added to it. If we weren't holding the lock we'd have to signal
    52             // m_performWorkEvent to make sure the work item got picked up.
    53             return;
    54         }
    55     }
    56 
    57     queue->performWorkOnRegisteredWorkThread();
    58 }
    5934
    6035DWORD WorkQueue::workThreadCallback(void* context)
     
    12095void WorkQueue::platformInvalidate()
    12196{
    122 #if !ASSERT_DISABLED
    123     MutexLocker lock(m_handlesLock);
    124     ASSERT(m_handles.isEmpty());
    125 #endif
    126 
    12797    // FIXME: We need to ensure that any timer-queue timers that fire after this point don't try to
    12898    // access this WorkQueue <http://webkit.org/b/44690>.
     
    222192}
    223193
    224 void WorkQueue::unregisterWaitAndDestroyItemSoon(PassRefPtr<HandleWorkItem> item)
    225 {
    226     // We're going to make a blocking call to ::UnregisterWaitEx before closing the handle. (The
    227     // blocking version of ::UnregisterWaitEx is much simpler than the non-blocking version.) If we
    228     // do this on the current thread, we'll deadlock if we're currently in a callback function for
    229     // 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 can
    240     // 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 
    249194} // namespace WTF
Note: See TracChangeset for help on using the changeset viewer.