diff options
Diffstat (limited to 'Source/WebKit2/Platform/mac/WorkQueueMac.cpp')
-rw-r--r-- | Source/WebKit2/Platform/mac/WorkQueueMac.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Source/WebKit2/Platform/mac/WorkQueueMac.cpp b/Source/WebKit2/Platform/mac/WorkQueueMac.cpp index ded1d7ac3..9e57e150c 100644 --- a/Source/WebKit2/Platform/mac/WorkQueueMac.cpp +++ b/Source/WebKit2/Platform/mac/WorkQueueMac.cpp @@ -30,39 +30,30 @@ #include <mach/mach_port.h> #include <wtf/PassOwnPtr.h> -struct WorkQueueAndFunction { - WorkQueueAndFunction(WorkQueue* workQueue, const Function<void()>& function) - : workQueue(workQueue) - , function(function) - { - } - - WorkQueue* workQueue; - Function<void()> function; -}; - void WorkQueue::executeFunction(void* context) { - OwnPtr<WorkQueueAndFunction> workQueueAndFunction = adoptPtr(static_cast<WorkQueueAndFunction*>(context)); + WorkQueue* queue = static_cast<WorkQueue*>(dispatch_get_context(dispatch_get_current_queue())); + OwnPtr<Function<void()> > function = adoptPtr(static_cast<Function<void()>*>(context)); { - MutexLocker locker(workQueueAndFunction->workQueue->m_isValidMutex); - if (!workQueueAndFunction->workQueue->m_isValid) + MutexLocker locker(queue->m_isValidMutex); + if (!queue->m_isValid) return; } - (workQueueAndFunction->function)(); + (*function)(); } void WorkQueue::dispatch(const Function<void()>& function) { - dispatch_async_f(m_dispatchQueue, new WorkQueueAndFunction(this, function), executeFunction); + dispatch_async_f(m_dispatchQueue, new Function<void()>(function), executeFunction); } void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay) { dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC); - dispatch_after_f(delayTime, m_dispatchQueue, new WorkQueueAndFunction(this, function), executeFunction); + + dispatch_after_f(delayTime, m_dispatchQueue, new Function<void()>(function), executeFunction); } class WorkQueue::EventSource { @@ -164,7 +155,7 @@ void WorkQueue::unregisterMachPortEventHandler(mach_port_t machPort) ASSERT(m_eventSources.contains(machPort)); - EventSource* eventSource = it->value; + EventSource* eventSource = it->second; // Cancel and release the source. It will be deleted in its finalize handler. dispatch_source_cancel(eventSource->dispatchSource()); dispatch_release(eventSource->dispatchSource()); |