Changeset 201493 in webkit
- Timestamp:
- May 28, 2016 9:20:06 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r201483 r201493 1 2016-05-28 Chris Dumez <cdumez@apple.com> 2 3 Templatize NoncopyableFunction class similarly to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=158185 5 6 Reviewed by Darin Adler. 7 8 Templatize NoncopyableFunction class similarly to std::function, so 9 that it can be used as a std::function replacement in more places. 10 11 Previously, NoncopyableFunction could only support "void()" lambdas. 12 13 * wtf/FunctionDispatcher.h: 14 * wtf/MainThread.cpp: 15 (WTF::functionQueue): 16 (WTF::dispatchFunctionsFromMainThread): 17 (WTF::callOnMainThread): 18 * wtf/MainThread.h: 19 * wtf/NoncopyableFunction.h: 20 * wtf/RunLoop.cpp: 21 (WTF::RunLoop::performWork): 22 (WTF::RunLoop::dispatch): 23 * wtf/RunLoop.h: 24 * wtf/WorkQueue.h: 25 * wtf/cocoa/WorkQueueCocoa.cpp: 26 (WTF::WorkQueue::dispatch): 27 (WTF::WorkQueue::dispatchAfter): 28 * wtf/efl/DispatchQueueWorkItemEfl.h: 29 (WorkItem::WorkItem): 30 (TimerWorkItem::create): 31 (TimerWorkItem::TimerWorkItem): 32 * wtf/efl/WorkQueueEfl.cpp: 33 (WTF::WorkQueue::dispatch): 34 (WTF::WorkQueue::dispatchAfter): 35 * wtf/generic/RunLoopGeneric.cpp: 36 (WTF::RunLoop::TimerBase::ScheduledTask::create): 37 (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): 38 (WTF::RunLoop::dispatchAfter): 39 * wtf/generic/WorkQueueGeneric.cpp: 40 (WorkQueue::dispatch): 41 (WorkQueue::dispatchAfter): 42 * wtf/glib/RunLoopGLib.cpp: 43 (WTF::DispatchAfterContext::DispatchAfterContext): 44 (WTF::RunLoop::dispatchAfter): 45 * wtf/win/WorkItemWin.cpp: 46 (WTF::WorkItemWin::WorkItemWin): 47 (WTF::WorkItemWin::create): 48 (WTF::HandleWorkItem::HandleWorkItem): 49 (WTF::HandleWorkItem::createByAdoptingHandle): 50 * wtf/win/WorkItemWin.h: 51 (WTF::WorkItemWin::function): 52 * wtf/win/WorkQueueWin.cpp: 53 (WTF::WorkQueue::dispatch): 54 (WTF::WorkQueue::dispatchAfter): 55 1 56 2016-05-28 Dan Bernstein <mitz@apple.com> 2 57 -
trunk/Source/WTF/wtf/FunctionDispatcher.h
r201482 r201493 40 40 WTF_EXPORT_PRIVATE virtual ~FunctionDispatcher(); 41 41 42 virtual void dispatch(NoncopyableFunction &&) = 0;42 virtual void dispatch(NoncopyableFunction<void ()>&&) = 0; 43 43 44 44 protected: -
trunk/Source/WTF/wtf/MainThread.cpp
r201482 r201493 48 48 static StaticLock mainThreadFunctionQueueMutex; 49 49 50 static Deque<NoncopyableFunction >& functionQueue()51 { 52 static NeverDestroyed<Deque<NoncopyableFunction >> functionQueue;50 static Deque<NoncopyableFunction<void ()>>& functionQueue() 51 { 52 static NeverDestroyed<Deque<NoncopyableFunction<void ()>>> functionQueue; 53 53 return functionQueue; 54 54 } … … 121 121 auto startTime = std::chrono::steady_clock::now(); 122 122 123 NoncopyableFunction function;123 NoncopyableFunction<void ()> function; 124 124 125 125 while (true) { … … 145 145 } 146 146 147 void callOnMainThread(NoncopyableFunction && function)147 void callOnMainThread(NoncopyableFunction<void ()>&& function) 148 148 { 149 149 ASSERT(function); -
trunk/Source/WTF/wtf/MainThread.h
r201482 r201493 42 42 WTF_EXPORT_PRIVATE void initializeMainThread(); 43 43 44 WTF_EXPORT_PRIVATE void callOnMainThread(NoncopyableFunction &&);44 WTF_EXPORT_PRIVATE void callOnMainThread(NoncopyableFunction<void ()>&&); 45 45 46 46 #if PLATFORM(COCOA) -
trunk/Source/WTF/wtf/NoncopyableFunction.h
r201483 r201493 31 31 namespace WTF { 32 32 33 // FIXME: We could make this templated to support other lambdas than void() and make this more reusable. 34 class NoncopyableFunction { 33 template<typename> class NoncopyableFunction; 34 35 template <typename Out, typename... In> 36 class NoncopyableFunction<Out(In...)> { 35 37 public: 36 38 NoncopyableFunction() = default; … … 42 44 } 43 45 44 void operator()() const46 Out operator()(In... in) const 45 47 { 46 48 if (m_callableWrapper) 47 m_callableWrapper->call(); 49 return m_callableWrapper->call(std::forward<In>(in)...); 50 return Out(); 48 51 } 49 52 … … 69 72 virtual ~CallableWrapperBase() { } 70 73 71 virtual void call() = 0;74 virtual Out call(In...) = 0; 72 75 }; 73 76 74 77 template<typename CallableType> 75 class CallableWrapper final: public CallableWrapperBase {78 class CallableWrapper : public CallableWrapperBase { 76 79 public: 77 80 explicit CallableWrapper(CallableType&& callable) … … 83 86 CallableWrapper& operator=(const CallableWrapper&) = delete; 84 87 85 void call() final { m_callable(); }88 Out call(In... in) final { return m_callable(std::forward<In>(in)...); } 86 89 87 90 private: -
trunk/Source/WTF/wtf/RunLoop.cpp
r201464 r201493 92 92 size_t functionsToHandle = 0; 93 93 { 94 NoncopyableFunction function;94 NoncopyableFunction<void ()> function; 95 95 { 96 96 MutexLocker locker(m_functionQueueLock); … … 107 107 108 108 for (size_t functionsHandled = 1; functionsHandled < functionsToHandle; ++functionsHandled) { 109 NoncopyableFunction function;109 NoncopyableFunction<void ()> function; 110 110 { 111 111 MutexLocker locker(m_functionQueueLock); … … 124 124 } 125 125 126 void RunLoop::dispatch(NoncopyableFunction && function)126 void RunLoop::dispatch(NoncopyableFunction<void ()>&& function) 127 127 { 128 128 { -
trunk/Source/WTF/wtf/RunLoop.h
r201464 r201493 60 60 ~RunLoop(); 61 61 62 void dispatch(NoncopyableFunction &&) override;62 void dispatch(NoncopyableFunction<void ()>&&) override; 63 63 64 64 WTF_EXPORT_PRIVATE static void run(); … … 80 80 81 81 #if USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP) 82 WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction &&);82 WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction<void ()>&&); 83 83 #endif 84 84 … … 156 156 157 157 Mutex m_functionQueueLock; 158 Deque<NoncopyableFunction > m_functionQueue;158 Deque<NoncopyableFunction<void ()>> m_functionQueue; 159 159 160 160 #if USE(WINDOWS_EVENT_LOOP) -
trunk/Source/WTF/wtf/WorkQueue.h
r201464 r201493 73 73 virtual ~WorkQueue(); 74 74 75 WTF_EXPORT_PRIVATE void dispatch(NoncopyableFunction &&) override;76 WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction &&);75 WTF_EXPORT_PRIVATE void dispatch(NoncopyableFunction<void ()>&&) override; 76 WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction<void ()>&&); 77 77 78 78 WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, const std::function<void (size_t index)>&); -
trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
r201464 r201493 29 29 namespace WTF { 30 30 31 void WorkQueue::dispatch(NoncopyableFunction && function)31 void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function) 32 32 { 33 33 ref(); 34 auto* functionPtr = new NoncopyableFunction (WTFMove(function));34 auto* functionPtr = new NoncopyableFunction<void ()>(WTFMove(function)); 35 35 dispatch_async(m_dispatchQueue, ^{ 36 36 (*functionPtr)(); … … 40 40 } 41 41 42 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction && function)42 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function) 43 43 { 44 44 ref(); 45 auto* functionPtr = new NoncopyableFunction (WTFMove(function));45 auto* functionPtr = new NoncopyableFunction<void ()>(WTFMove(function)); 46 46 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, ^{ 47 47 (*functionPtr)(); -
trunk/Source/WTF/wtf/efl/DispatchQueueWorkItemEfl.h
r201464 r201493 35 35 class WorkItem { 36 36 public: 37 WorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction && function)37 WorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function) 38 38 : m_workQueue(WTFMove(workQueue)) 39 39 , m_function(WTFMove(function)) … … 45 45 private: 46 46 Ref<WorkQueue> m_workQueue; 47 NoncopyableFunction m_function;47 NoncopyableFunction<void ()> m_function; 48 48 }; 49 49 50 50 class TimerWorkItem : public WorkItem { 51 51 public: 52 static std::unique_ptr<TimerWorkItem> create(Ref<WorkQueue>&& workQueue, NoncopyableFunction && function, std::chrono::nanoseconds delayNanoSeconds)52 static std::unique_ptr<TimerWorkItem> create(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function, std::chrono::nanoseconds delayNanoSeconds) 53 53 { 54 54 ASSERT(delayNanoSeconds.count() >= 0); … … 59 59 60 60 protected: 61 TimerWorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction && function, double expirationTimeNanoSeconds)61 TimerWorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function, double expirationTimeNanoSeconds) 62 62 : WorkItem(WTFMove(workQueue), WTFMove(function)) 63 63 , m_expirationTimeNanoSeconds(expirationTimeNanoSeconds) -
trunk/Source/WTF/wtf/efl/WorkQueueEfl.cpp
r201464 r201493 55 55 } 56 56 57 void WorkQueue::dispatch(NoncopyableFunction && function)57 void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function) 58 58 { 59 59 if (!m_dispatchQueue) … … 63 63 } 64 64 65 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction && function)65 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function) 66 66 { 67 67 if (!m_dispatchQueue) -
trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp
r201479 r201493 33 33 WTF_MAKE_NONCOPYABLE(ScheduledTask); 34 34 public: 35 static RefPtr<ScheduledTask> create(NoncopyableFunction && function, double interval, bool repeating)35 static RefPtr<ScheduledTask> create(NoncopyableFunction<void ()>&& function, double interval, bool repeating) 36 36 { 37 37 return adoptRef(new ScheduledTask(WTFMove(function), interval, repeating)); 38 38 } 39 39 40 ScheduledTask(NoncopyableFunction && function, double interval, bool repeating)40 ScheduledTask(NoncopyableFunction<void ()>&& function, double interval, bool repeating) 41 41 : m_function(WTFMove(function)) 42 42 , m_fireInterval(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(interval))) … … 91 91 92 92 private: 93 NoncopyableFunction m_function;93 NoncopyableFunction<void ()> m_function; 94 94 Condition::Clock::time_point m_scheduledTimePoint; 95 95 std::chrono::microseconds m_fireInterval; … … 238 238 } 239 239 240 void RunLoop::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction && function)240 void RunLoop::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction<void ()>&& function) 241 241 { 242 242 LockHolder locker(m_loopLock); -
trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp
r201464 r201493 82 82 } 83 83 84 void WorkQueue::dispatch(NoncopyableFunction && function)84 void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function) 85 85 { 86 86 RefPtr<WorkQueue> protect(this); … … 90 90 } 91 91 92 void WorkQueue::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction && function)92 void WorkQueue::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction<void ()>&& function) 93 93 { 94 94 RefPtr<WorkQueue> protect(this); -
trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp
r201464 r201493 125 125 WTF_MAKE_FAST_ALLOCATED; 126 126 public: 127 DispatchAfterContext(NoncopyableFunction && function)127 DispatchAfterContext(NoncopyableFunction<void ()>&& function) 128 128 : m_function(WTFMove(function)) 129 129 { … … 136 136 137 137 private: 138 NoncopyableFunction m_function;138 NoncopyableFunction<void ()> m_function; 139 139 }; 140 140 141 void RunLoop::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction && function)141 void RunLoop::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function) 142 142 { 143 143 GRefPtr<GSource> source = adoptGRef(g_timeout_source_new(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count())); -
trunk/Source/WTF/wtf/win/WorkItemWin.cpp
r201464 r201493 33 33 namespace WTF { 34 34 35 WorkItemWin::WorkItemWin(NoncopyableFunction && function, WorkQueue* queue)35 WorkItemWin::WorkItemWin(NoncopyableFunction<void ()>&& function, WorkQueue* queue) 36 36 : m_function(WTFMove(function)) 37 37 , m_queue(queue) … … 39 39 } 40 40 41 RefPtr<WorkItemWin> WorkItemWin::create(NoncopyableFunction && function, WorkQueue* queue)41 RefPtr<WorkItemWin> WorkItemWin::create(NoncopyableFunction<void ()>&& function, WorkQueue* queue) 42 42 { 43 43 return adoptRef(new WorkItemWin(WTFMove(function), queue)); … … 48 48 } 49 49 50 HandleWorkItem::HandleWorkItem(HANDLE handle, NoncopyableFunction && function, WorkQueue* queue)50 HandleWorkItem::HandleWorkItem(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue) 51 51 : WorkItemWin(WTFMove(function), queue) 52 52 , m_handle(handle) … … 56 56 } 57 57 58 RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, NoncopyableFunction && function, WorkQueue* queue)58 RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue) 59 59 { 60 60 return adoptRef(new HandleWorkItem(handle, WTFMove(function), queue)); -
trunk/Source/WTF/wtf/win/WorkItemWin.h
r201464 r201493 40 40 class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> { 41 41 public: 42 static RefPtr<WorkItemWin> create(NoncopyableFunction &&, WorkQueue*);42 static RefPtr<WorkItemWin> create(NoncopyableFunction<void ()>&&, WorkQueue*); 43 43 virtual ~WorkItemWin(); 44 44 45 NoncopyableFunction & function() { return m_function; }45 NoncopyableFunction<void ()>& function() { return m_function; } 46 46 WorkQueue* queue() const { return m_queue.get(); } 47 47 48 48 protected: 49 WorkItemWin(NoncopyableFunction &&, WorkQueue*);49 WorkItemWin(NoncopyableFunction<void ()>&&, WorkQueue*); 50 50 51 51 private: 52 NoncopyableFunction m_function;52 NoncopyableFunction<void ()> m_function; 53 53 RefPtr<WorkQueue> m_queue; 54 54 }; … … 56 56 class HandleWorkItem : public WorkItemWin { 57 57 public: 58 static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, NoncopyableFunction &&, WorkQueue*);58 static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*); 59 59 virtual ~HandleWorkItem(); 60 60 … … 63 63 64 64 private: 65 HandleWorkItem(HANDLE, NoncopyableFunction &&, WorkQueue*);65 HandleWorkItem(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*); 66 66 67 67 HANDLE m_handle; -
trunk/Source/WTF/wtf/win/WorkQueueWin.cpp
r201464 r201493 130 130 } 131 131 132 void WorkQueue::dispatch(NoncopyableFunction && function)132 void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function) 133 133 { 134 134 MutexLocker locker(m_workItemQueueLock); … … 150 150 151 151 WorkQueue* queue; 152 NoncopyableFunction function;152 NoncopyableFunction<void ()> function; 153 153 Mutex timerMutex; 154 154 HANDLE timer; … … 181 181 } 182 182 183 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction && function)183 void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function) 184 184 { 185 185 ASSERT(m_timerQueue); -
trunk/Source/WebCore/ChangeLog
r201492 r201493 1 2016-05-28 Chris Dumez <cdumez@apple.com> 2 3 Templatize NoncopyableFunction class similarly to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=158185 5 6 Reviewed by Darin Adler. 7 8 Templatize NoncopyableFunction class similarly to std::function, so 9 that it can be used as a std::function replacement in more places. 10 11 Previously, NoncopyableFunction could only support "void()" lambdas. 12 13 * Modules/mediastream/MediaEndpointPeerConnection.cpp: 14 (WebCore::MediaEndpointPeerConnection::runTask): 15 * Modules/mediastream/MediaEndpointPeerConnection.h: 16 * fileapi/AsyncFileStream.cpp: 17 (WebCore::callOnFileThread): 18 (WebCore::AsyncFileStream::perform): 19 (WebCore::AsyncFileStream::getSize): 20 (WebCore::AsyncFileStream::openForRead): 21 (WebCore::AsyncFileStream::openForWrite): 22 (WebCore::AsyncFileStream::write): 23 * fileapi/AsyncFileStream.h: 24 * page/scrolling/ScrollingThread.cpp: 25 (WebCore::ScrollingThread::dispatch): 26 (WebCore::ScrollingThread::dispatchBarrier): 27 (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): 28 * page/scrolling/ScrollingThread.h: 29 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: 30 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: 31 (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): 32 * platform/mediastream/MediaStreamPrivate.cpp: 33 (WebCore::MediaStreamPrivate::scheduleDeferredTask): 34 * platform/mediastream/MediaStreamPrivate.h: 35 * platform/mediastream/mac/AVMediaCaptureSource.h: 36 * platform/mediastream/mac/AVMediaCaptureSource.mm: 37 (WebCore::AVMediaCaptureSource::scheduleDeferredTask): 38 1 39 2016-05-28 Alexey Proskuryakov <ap@apple.com> 2 40 -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp
r201482 r201493 96 96 } 97 97 98 void MediaEndpointPeerConnection::runTask(NoncopyableFunction && task)98 void MediaEndpointPeerConnection::runTask(NoncopyableFunction<void ()>&& task) 99 99 { 100 100 if (m_dtlsFingerprint.isNull()) { -
trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h
r201482 r201493 79 79 80 80 private: 81 void runTask(NoncopyableFunction &&);81 void runTask(NoncopyableFunction<void ()>&&); 82 82 void startRunningTasks(); 83 83 … … 93 93 std::unique_ptr<MediaEndpoint> m_mediaEndpoint; 94 94 95 NoncopyableFunction m_initialDeferredTask;95 NoncopyableFunction<void ()> m_initialDeferredTask; 96 96 97 97 std::unique_ptr<SDPProcessor> m_sdpProcessor; -
trunk/Source/WebCore/fileapi/AsyncFileStream.cpp
r201482 r201493 65 65 } 66 66 67 static void callOnFileThread(NoncopyableFunction && function)67 static void callOnFileThread(NoncopyableFunction<void ()>&& function) 68 68 { 69 69 ASSERT(isMainThread()); 70 70 ASSERT(function); 71 71 72 static NeverDestroyed<MessageQueue<NoncopyableFunction >> queue;72 static NeverDestroyed<MessageQueue<NoncopyableFunction<void ()>>> queue; 73 73 74 74 static std::once_flag createFileThreadOnce; … … 91 91 }); 92 92 93 queue.get().append(std::make_unique<NoncopyableFunction >(WTFMove(function)));93 queue.get().append(std::make_unique<NoncopyableFunction<void ()>>(WTFMove(function))); 94 94 } 95 95 … … 115 115 } 116 116 117 void AsyncFileStream::perform( std::function<std::function<void(FileStreamClient&)>(FileStream&)>&& operation)117 void AsyncFileStream::perform(NoncopyableFunction<std::function<void(FileStreamClient&)>(FileStream&)>&& operation) 118 118 { 119 119 auto& internals = *m_internals; … … 135 135 void AsyncFileStream::getSize(const String& path, double expectedModificationTime) 136 136 { 137 StringCapture capturedPath(path);138 137 // FIXME: Explicit return type here and in all the other cases like this below is a workaround for a deficiency 139 138 // in the Windows compiler at the time of this writing. Could remove it if that is resolved. 140 perform([ capturedPath, expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {141 long long size = stream.getSize( capturedPath.string(), expectedModificationTime);139 perform([path = path.isolatedCopy(), expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> { 140 long long size = stream.getSize(path, expectedModificationTime); 142 141 return [size](FileStreamClient& client) { 143 142 client.didGetSize(size); … … 148 147 void AsyncFileStream::openForRead(const String& path, long long offset, long long length) 149 148 { 150 StringCapture capturedPath(path);151 149 // FIXME: Explicit return type here is a workaround for a deficiency in the Windows compiler at the time of this writing. 152 perform([ capturedPath, offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {153 bool success = stream.openForRead( capturedPath.string(), offset, length);150 perform([path = path.isolatedCopy(), offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> { 151 bool success = stream.openForRead(path, offset, length); 154 152 return [success](FileStreamClient& client) { 155 153 client.didOpen(success); … … 160 158 void AsyncFileStream::openForWrite(const String& path) 161 159 { 162 StringCapture capturedPath(path); 163 perform([capturedPath](FileStream& stream) -> std::function<void(FileStreamClient&)> { 164 bool success = stream.openForWrite(capturedPath.string()); 160 perform([path = path.isolatedCopy()](FileStream& stream) -> std::function<void(FileStreamClient&)> { 161 bool success = stream.openForWrite(path); 165 162 return [success](FileStreamClient& client) { 166 163 client.didOpen(success); … … 189 186 void AsyncFileStream::write(const URL& blobURL, long long position, int length) 190 187 { 191 URLCapture capturedURL(blobURL); 192 perform([capturedURL, position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> { 193 int bytesWritten = stream.write(capturedURL.url(), position, length); 188 perform([blobURL = blobURL.isolatedCopy(), position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> { 189 int bytesWritten = stream.write(blobURL, position, length); 194 190 return [bytesWritten](FileStreamClient& client) { 195 191 client.didWrite(bytesWritten); -
trunk/Source/WebCore/fileapi/AsyncFileStream.h
r201482 r201493 35 35 #include <functional> 36 36 #include <wtf/Forward.h> 37 #include <wtf/NoncopyableFunction.h> 37 38 38 39 namespace WebCore { … … 57 58 private: 58 59 void start(); 59 void perform( std::function<std::function<void(FileStreamClient&)>(FileStream&)>&&);60 void perform(NoncopyableFunction<std::function<void(FileStreamClient&)>(FileStream&)>&&); 60 61 61 62 struct Internals; -
trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp
r201482 r201493 46 46 } 47 47 48 void ScrollingThread::dispatch(NoncopyableFunction && function)48 void ScrollingThread::dispatch(NoncopyableFunction<void ()>&& function) 49 49 { 50 50 auto& scrollingThread = ScrollingThread::singleton(); … … 59 59 } 60 60 61 void ScrollingThread::dispatchBarrier(NoncopyableFunction && function)61 void ScrollingThread::dispatchBarrier(NoncopyableFunction<void ()>&& function) 62 62 { 63 63 dispatch([function = WTFMove(function)]() mutable { … … 105 105 ASSERT(isCurrentThread()); 106 106 107 Vector<NoncopyableFunction > functions;107 Vector<NoncopyableFunction<void ()>> functions; 108 108 109 109 { -
trunk/Source/WebCore/page/scrolling/ScrollingThread.h
r201482 r201493 49 49 public: 50 50 static bool isCurrentThread(); 51 WEBCORE_EXPORT static void dispatch(NoncopyableFunction &&);51 WEBCORE_EXPORT static void dispatch(NoncopyableFunction<void ()>&&); 52 52 53 53 // Will dispatch the given function on the main thread once all pending functions 54 54 // on the scrolling thread have finished executing. Used for synchronization purposes. 55 WEBCORE_EXPORT static void dispatchBarrier(NoncopyableFunction &&);55 WEBCORE_EXPORT static void dispatchBarrier(NoncopyableFunction<void ()>&&); 56 56 57 57 private: … … 81 81 82 82 Lock m_functionsMutex; 83 Vector<NoncopyableFunction > m_functions;83 Vector<NoncopyableFunction<void ()>> m_functions; 84 84 85 85 #if PLATFORM(COCOA) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
r201482 r201493 144 144 void renderingModeChanged(); 145 145 146 void scheduleDeferredTask(NoncopyableFunction &&);146 void scheduleDeferredTask(NoncopyableFunction<void ()>&&); 147 147 148 148 enum DisplayMode { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r201482 r201493 625 625 } 626 626 627 void MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask(NoncopyableFunction && function)627 void MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask(NoncopyableFunction<void ()>&& function) 628 628 { 629 629 ASSERT(function); -
trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
r201482 r201493 300 300 } 301 301 302 void MediaStreamPrivate::scheduleDeferredTask(NoncopyableFunction && function)302 void MediaStreamPrivate::scheduleDeferredTask(NoncopyableFunction<void ()>&& function) 303 303 { 304 304 ASSERT(function); -
trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h
r201482 r201493 113 113 void updateActiveVideoTrack(); 114 114 115 void scheduleDeferredTask(NoncopyableFunction &&);115 void scheduleDeferredTask(NoncopyableFunction<void ()>&&); 116 116 117 117 WeakPtrFactory<MediaStreamPrivate> m_weakPtrFactory; -
trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h
r201482 r201493 87 87 void setAudioSampleBufferDelegate(AVCaptureAudioDataOutput*); 88 88 89 void scheduleDeferredTask(NoncopyableFunction &&);89 void scheduleDeferredTask(NoncopyableFunction<void ()>&&); 90 90 91 91 private: -
trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm
r201482 r201493 241 241 } 242 242 243 void AVMediaCaptureSource::scheduleDeferredTask(NoncopyableFunction && function)243 void AVMediaCaptureSource::scheduleDeferredTask(NoncopyableFunction<void ()>&& function) 244 244 { 245 245 ASSERT(function); -
trunk/Source/WebKit/ChangeLog
r201482 r201493 1 2016-05-28 Chris Dumez <cdumez@apple.com> 2 3 Templatize NoncopyableFunction class similarly to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=158185 5 6 Reviewed by Darin Adler. 7 8 Templatize NoncopyableFunction class similarly to std::function, so 9 that it can be used as a std::function replacement in more places. 10 11 Previously, NoncopyableFunction could only support "void()" lambdas. 12 13 * Storage/StorageSyncManager.cpp: 14 (WebCore::StorageSyncManager::dispatch): 15 * Storage/StorageSyncManager.h: 16 * Storage/StorageThread.cpp: 17 (WebCore::StorageThread::dispatch): 18 (WebCore::StorageThread::terminate): 19 * Storage/StorageThread.h: 20 1 21 2016-05-27 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebKit/Storage/StorageSyncManager.cpp
r201482 r201493 64 64 } 65 65 66 void StorageSyncManager::dispatch(NoncopyableFunction && function)66 void StorageSyncManager::dispatch(NoncopyableFunction<void ()>&& function) 67 67 { 68 68 ASSERT(isMainThread()); -
trunk/Source/WebKit/Storage/StorageSyncManager.h
r201482 r201493 44 44 ~StorageSyncManager(); 45 45 46 void dispatch(NoncopyableFunction &&);46 void dispatch(NoncopyableFunction<void ()>&&); 47 47 void close(); 48 48 -
trunk/Source/WebKit/Storage/StorageThread.cpp
r201482 r201493 75 75 } 76 76 77 void StorageThread::dispatch(NoncopyableFunction && function)77 void StorageThread::dispatch(NoncopyableFunction<void ()>&& function) 78 78 { 79 79 ASSERT(isMainThread()); 80 80 ASSERT(!m_queue.killed() && m_threadID); 81 m_queue.append(std::make_unique<NoncopyableFunction >(WTFMove(function)));81 m_queue.append(std::make_unique<NoncopyableFunction<void ()>>(WTFMove(function))); 82 82 } 83 83 … … 91 91 return; 92 92 93 m_queue.append(std::make_unique<NoncopyableFunction >([this] {93 m_queue.append(std::make_unique<NoncopyableFunction<void ()>>([this] { 94 94 performTerminate(); 95 95 })); -
trunk/Source/WebKit/Storage/StorageThread.h
r201482 r201493 47 47 void terminate(); 48 48 49 void dispatch(NoncopyableFunction &&);49 void dispatch(NoncopyableFunction<void ()>&&); 50 50 51 51 static void releaseFastMallocFreeMemoryInAllThreads(); … … 60 60 61 61 ThreadIdentifier m_threadID; 62 MessageQueue<NoncopyableFunction > m_queue;62 MessageQueue<NoncopyableFunction<void ()>> m_queue; 63 63 }; 64 64 -
trunk/Source/WebKit2/ChangeLog
r201492 r201493 1 2016-05-28 Chris Dumez <cdumez@apple.com> 2 3 Templatize NoncopyableFunction class similarly to std::function 4 https://bugs.webkit.org/show_bug.cgi?id=158185 5 6 Reviewed by Darin Adler. 7 8 Templatize NoncopyableFunction class similarly to std::function, so 9 that it can be used as a std::function replacement in more places. 10 11 Previously, NoncopyableFunction could only support "void()" lambdas. 12 13 * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: 14 (WebKit::NetworkCache::runTaskInQueue): 15 1 16 2016-05-28 Alexey Proskuryakov <ap@apple.com> 2 17 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
r201484 r201493 70 70 } 71 71 72 static inline void runTaskInQueue(NoncopyableFunction && task, WorkQueue* queue)72 static inline void runTaskInQueue(NoncopyableFunction<void ()>&& task, WorkQueue* queue) 73 73 { 74 74 if (queue) {
Note: See TracChangeset
for help on using the changeset viewer.