Changeset 224137 in webkit
- Timestamp:
- Oct 27, 2017 5:09:47 PM (6 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r224136 r224137 1 2017-10-27 Yousuke Kimoto <yousuke.kimoto@sony.com> 2 3 [WinCairo] Add WTF files for wincairo webkit 4 https://bugs.webkit.org/show_bug.cgi?id=176894 5 6 Reviewed by Alex Christensen. 7 8 * wtf/PlatformWin.cmake: 9 * wtf/WorkQueue.cpp: 10 * wtf/WorkQueue.h: 11 * wtf/win/Win32Handle.h: 12 * wtf/win/WorkItemContext.cpp: Added. 13 (WTF::WorkItemContext::WorkItemContext): 14 (WTF::WorkItemContext::create): 15 (WTF::WorkItemContext::~WorkItemContext): 16 * wtf/win/WorkItemContext.h: Added. 17 (WTF::WorkItemContext::handle): 18 (WTF::WorkItemContext::waitHandle): 19 (WTF::WorkItemContext::Function<void): 20 (WTF::WorkItemContext::queue const): 21 * wtf/win/WorkQueueWin.cpp: 22 (WTF::WorkQueue::handleCallback): 23 (WTF::WorkQueue::registerHandle): 24 (WTF::WorkQueue::unregisterAndCloseHandle): 25 (WTF::WorkQueue::unregisterWaitAndDestroyItemSoon): 26 (WTF::WorkQueue::unregisterWaitAndDestroyItemCallback): 27 1 28 2017-10-27 Keith Miller <keith_miller@apple.com> 2 29 -
trunk/Source/WTF/wtf/PlatformWin.cmake
r221768 r224137 12 12 win/MemoryPressureHandlerWin.cpp 13 13 win/RunLoopWin.cpp 14 win/WorkItemContext.cpp 14 15 win/WorkQueueWin.cpp 15 16 ) -
trunk/Source/WTF/wtf/WorkQueue.cpp
-
Property
svn:executable
set to
*
r217998 r224137 1 1 /* 2 2 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2017 Sony Interactive Entertainment Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 38 39 #include <wtf/text/WTFString.h> 39 40 #include <wtf/threads/BinarySemaphore.h> 41 42 #if USE(WINDOWS_EVENT_LOOP) 43 #include <wtf/win/WorkItemContext.h> 44 #endif 40 45 41 46 namespace WTF { -
Property
svn:executable
set to
-
trunk/Source/WTF/wtf/WorkQueue.h
r218594 r224137 2 2 * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. 3 3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. 4 * Copyright (C) 2017 Sony Interactive Entertainment Inc. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 38 39 39 40 #if USE(WINDOWS_EVENT_LOOP) 41 #include <wtf/HashMap.h> 40 42 #include <wtf/ThreadingPrimitives.h> 41 43 #include <wtf/Vector.h> … … 49 51 namespace WTF { 50 52 53 #if USE(WINDOWS_EVENT_LOOP) 54 class WorkItemContext; 55 #endif 56 51 57 class WorkQueue final : public FunctionDispatcher { 58 52 59 public: 53 60 enum class Type { … … 75 82 #elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP) 76 83 RunLoop& runLoop() const { return *m_runLoop; } 84 #elif USE(WINDOWS_EVENT_LOOP) 85 WTF_EXPORT_PRIVATE void registerHandle(HANDLE, Function<void()>&&); 86 WTF_EXPORT_PRIVATE void unregisterAndCloseHandle(HANDLE); 77 87 #endif 78 88 … … 84 94 85 95 #if USE(WINDOWS_EVENT_LOOP) 96 static void CALLBACK handleCallback(void* context, BOOLEAN timerOrWaitFired); 86 97 static void CALLBACK timerCallback(void* context, BOOLEAN timerOrWaitFired); 87 98 static DWORD WINAPI workThreadCallback(void* context); … … 90 101 void unregisterAsWorkThread(); 91 102 void performWorkOnRegisteredWorkThread(); 103 104 static void unregisterWaitAndDestroyItemSoon(Ref<WorkItemContext>&&); 105 static DWORD WINAPI unregisterWaitAndDestroyItemCallback(void* context); 92 106 #endif 93 107 … … 100 114 Mutex m_functionQueueLock; 101 115 Vector<Function<void()>> m_functionQueue; 116 117 Mutex m_itemsMapLock; 118 HashMap<HANDLE, Ref<WorkItemContext>> m_itemsMap; 102 119 103 120 HANDLE m_timerQueue; -
trunk/Source/WTF/wtf/win/Win32Handle.h
r213214 r224137 33 33 class Win32Handle { 34 34 WTF_MAKE_NONCOPYABLE(Win32Handle); 35 36 friend class WorkQueue; 37 35 38 public: 36 39 Win32Handle() : m_handle(INVALID_HANDLE_VALUE) { } -
trunk/Source/WTF/wtf/win/WorkQueueWin.cpp
r221425 r224137 1 1 /* 2 * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 2 * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. 3 * Copyright (C) 2017 Sony Interactive Entertainment Inc. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 * THE POSSIBILITY OF SUCH DAMAGE. 25 */ 25 26 26 27 #include "config.h" … … 29 30 #include <wtf/MathExtras.h> 30 31 #include <wtf/Threading.h> 32 #include <wtf/win/WorkItemContext.h> 31 33 32 34 namespace WTF { 35 36 void WorkQueue::handleCallback(void* data, BOOLEAN timerOrWaitFired) 37 { 38 ASSERT_ARG(data, data); 39 ASSERT_ARG(timerOrWaitFired, !timerOrWaitFired); 40 41 WorkItemContext* context = static_cast<WorkItemContext*>(data); 42 WorkQueue* queue = context->queue(); 43 44 RefPtr<WorkItemContext> protector(context); 45 queue->dispatch([protector] { 46 protector->function()(); 47 }); 48 } 49 50 void WorkQueue::registerHandle(HANDLE handle, Function<void()>&& function) 51 { 52 Ref<WorkItemContext> context = WorkItemContext::create(handle, nullptr, WTFMove(function), this); 53 54 if (!::RegisterWaitForSingleObject(&context->waitHandle().m_handle, handle, handleCallback, context.ptr(), INFINITE, WT_EXECUTEDEFAULT)) 55 ASSERT_WITH_MESSAGE(m_timerQueue, "::RegisterWaitForSingleObject %lu", ::GetLastError()); 56 57 MutexLocker lock(m_itemsMapLock); 58 ASSERT_ARG(handle, !m_itemsMap.contains(handle)); 59 m_itemsMap.set(handle, WTFMove(context)); 60 } 61 62 void WorkQueue::unregisterAndCloseHandle(HANDLE handle) 63 { 64 MutexLocker locker(m_itemsMapLock); 65 ASSERT_ARG(handle, m_itemsMap.contains(handle)); 66 67 unregisterWaitAndDestroyItemSoon(WTFMove(m_itemsMap.take(handle).value())); 68 } 33 69 34 70 DWORD WorkQueue::workThreadCallback(void* context) … … 191 227 } 192 228 229 void WorkQueue::unregisterWaitAndDestroyItemSoon(Ref<WorkItemContext>&& workItem) 230 { 231 // We're going to make a blocking call to ::UnregisterWaitEx before closing the handle. (The 232 // blocking version of ::UnregisterWaitEx is much simpler than the non-blocking version.) If we 233 // do this on the current thread, we'll deadlock if we're currently in a callback function for 234 // the wait we're unregistering. So instead we do it asynchronously on some other worker thread. 235 ::QueueUserWorkItem(unregisterWaitAndDestroyItemCallback, workItem.ptr(), WT_EXECUTEDEFAULT); 236 } 237 238 DWORD WINAPI WorkQueue::unregisterWaitAndDestroyItemCallback(void* data) 239 { 240 ASSERT_ARG(data, data); 241 WorkItemContext* context = static_cast<WorkItemContext*>(data); 242 243 // Now that we know we're not in a callback function for the wait we're unregistering, we can 244 // make a blocking call to ::UnregisterWaitEx. 245 if (!::UnregisterWaitEx(context->waitHandle().get(), INVALID_HANDLE_VALUE)) 246 ASSERT_WITH_MESSAGE(false, "::UnregisterWaitEx failed with '%s'", ::GetLastError()); 247 248 return 0; 249 } 250 193 251 } // namespace WTF
Note: See TracChangeset
for help on using the changeset viewer.