Title: [225684] trunk/Source/WTF
- Revision
- 225684
- Author
- utatane....@gmail.com
- Date
- 2017-12-08 10:37:08 -0800 (Fri, 08 Dec 2017)
Log Message
[WTF][Linux][GTK] Fix a minor bug in generic/WorkQueue when WorkQueue is immediately destroyed
https://bugs.webkit.org/show_bug.cgi?id=180586
Reviewed by Darin Adler.
If WorkQueue is created and destroyed immediately, RunLoop::stop can be called
befire calling RunLoop::run(). At that time WorkQueue thread is not stopped.
This patch dispatches a task stopping its own RunLoop to ensure stop is done.
We also clean up WorkQueue implementation not to include unnecessary fields,
lock, condition, and thread.
* wtf/WorkQueue.h:
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::platformInitialize):
(WorkQueue::platformInvalidate):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (225683 => 225684)
--- trunk/Source/WTF/ChangeLog 2017-12-08 18:27:18 UTC (rev 225683)
+++ trunk/Source/WTF/ChangeLog 2017-12-08 18:37:08 UTC (rev 225684)
@@ -1,5 +1,24 @@
2017-12-08 Yusuke Suzuki <utatane....@gmail.com>
+ [WTF][Linux][GTK] Fix a minor bug in generic/WorkQueue when WorkQueue is immediately destroyed
+ https://bugs.webkit.org/show_bug.cgi?id=180586
+
+ Reviewed by Darin Adler.
+
+ If WorkQueue is created and destroyed immediately, RunLoop::stop can be called
+ befire calling RunLoop::run(). At that time WorkQueue thread is not stopped.
+
+ This patch dispatches a task stopping its own RunLoop to ensure stop is done.
+ We also clean up WorkQueue implementation not to include unnecessary fields,
+ lock, condition, and thread.
+
+ * wtf/WorkQueue.h:
+ * wtf/generic/WorkQueueGeneric.cpp:
+ (WorkQueue::platformInitialize):
+ (WorkQueue::platformInvalidate):
+
+2017-12-08 Yusuke Suzuki <utatane....@gmail.com>
+
[WTF] Remove remaining use of Mutex
https://bugs.webkit.org/show_bug.cgi?id=180579
Modified: trunk/Source/WTF/wtf/WorkQueue.h (225683 => 225684)
--- trunk/Source/WTF/wtf/WorkQueue.h 2017-12-08 18:27:18 UTC (rev 225683)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2017-12-08 18:37:08 UTC (rev 225684)
@@ -118,9 +118,6 @@
HANDLE m_timerQueue;
#elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
- RefPtr<Thread> m_workQueueThread;
- Lock m_initializeRunLoopConditionMutex;
- Condition m_initializeRunLoopCondition;
RunLoop* m_runLoop;
#endif
};
Modified: trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp (225683 => 225684)
--- trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp 2017-12-08 18:27:18 UTC (rev 225683)
+++ trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp 2017-12-08 18:37:08 UTC (rev 225684)
@@ -30,29 +30,29 @@
#include "config.h"
#include "WorkQueue.h"
+#include <wtf/WallTime.h>
#include <wtf/text/WTFString.h>
+#include <wtf/threads/BinarySemaphore.h>
void WorkQueue::platformInitialize(const char* name, Type, QOS)
{
- LockHolder locker(m_initializeRunLoopConditionMutex);
- m_workQueueThread = Thread::create(name, [this] {
- {
- LockHolder locker(m_initializeRunLoopConditionMutex);
- m_runLoop = &RunLoop::current();
- m_initializeRunLoopCondition.notifyOne();
- }
+ BinarySemaphore semaphore;
+ Thread::create(name, [&] {
+ m_runLoop = &RunLoop::current();
+ semaphore.signal();
m_runLoop->run();
- });
- m_initializeRunLoopCondition.wait(m_initializeRunLoopConditionMutex);
+ })->detach();
+ semaphore.wait(WallTime::infinity());
}
void WorkQueue::platformInvalidate()
{
- if (m_runLoop)
- m_runLoop->stop();
- if (m_workQueueThread) {
- m_workQueueThread->detach();
- m_workQueueThread = nullptr;
+ if (m_runLoop) {
+ Ref<RunLoop> protector(*m_runLoop);
+ protector->stop();
+ protector->dispatch([] {
+ RunLoop::current().stop();
+ });
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes