Index: third_party/WebKit/Source/core/workers/WorkerThread.h |
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.h b/third_party/WebKit/Source/core/workers/WorkerThread.h |
index 8239c850ce8cceea70c168397effc07d95effd4a..af405a6d04b61d6c89b053079698463242f7f864 100644 |
--- a/third_party/WebKit/Source/core/workers/WorkerThread.h |
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.h |
@@ -37,6 +37,7 @@ |
#include "platform/LifecycleNotifier.h" |
#include "platform/WaitableEvent.h" |
#include "platform/WebTaskRunner.h" |
+#include "platform/scheduler/child/global_scope_scheduler.h" |
#include "public/platform/WebThread.h" |
#include "v8/include/v8.h" |
#include "wtf/Forward.h" |
@@ -92,7 +93,6 @@ class CORE_EXPORT WorkerThreadLifecycleContext final |
// If the running task is for debugger, it's guaranteed to finish without |
// any interruptions. |
// - Queued tasks never run. |
-// - postTask() and appendDebuggerTask() reject posting new tasks. |
class CORE_EXPORT WorkerThread : public WebThread::TaskObserver { |
public: |
// Represents how this thread is terminated. Used for UMA. Append only. |
@@ -137,9 +137,6 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver { |
return m_workerReportingProxy; |
} |
- void postTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>); |
- void postTask(const WebTraceLocation&, |
- std::unique_ptr<WTF::CrossThreadClosure>); |
void appendDebuggerTask(std::unique_ptr<CrossThreadClosure>); |
// Runs only debugger tasks while paused in debugger. |
@@ -176,6 +173,10 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver { |
return m_parentFrameTaskRunners.get(); |
} |
+ scheduler::GlobalScopeScheduler* globalScopeScheduler() const { |
+ return m_globalScopeScheduler.get(); |
+ } |
+ |
protected: |
WorkerThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&); |
@@ -243,18 +244,10 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver { |
// |m_threadStateMutex| acquired. |
void forciblyTerminateExecution(const MutexLocker&, ExitCode); |
- // Returns true if termination or shutdown sequence has started. This is |
- // thread safe. |
- // Note that this returns false when the sequence has already started but it |
- // hasn't been notified to the calling thread. |
- bool isInShutdown(); |
- |
+ void initializeSchedulerOnWorkerThread(WaitableEvent*); |
void initializeOnWorkerThread(std::unique_ptr<WorkerThreadStartupData>); |
void prepareForShutdownOnWorkerThread(); |
void performShutdownOnWorkerThread(); |
- template <WTF::FunctionThreadAffinity threadAffinity> |
- void performTaskOnWorkerThread( |
- std::unique_ptr<Function<void(), threadAffinity>> task); |
void performDebuggerTaskOnWorkerThread(std::unique_ptr<CrossThreadClosure>); |
void performDebuggerTaskDontWaitOnWorkerThread(); |
@@ -294,8 +287,18 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver { |
RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; |
WorkerReportingProxy& m_workerReportingProxy; |
+ |
CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; |
+ // Per-global-scope scheduler. Tasks managed by this scheduler are canceled |
+ // when the global scope is closed. |
+ std::unique_ptr<scheduler::GlobalScopeScheduler> m_globalScopeScheduler; |
Sami
2017/04/10 16:58:10
Would it make sense to call this a WorkerScheduler
nhiroki
2017/04/11 10:47:54
Current WorkerScheduler is a per-worker-thread obj
Sami
2017/04/11 11:52:02
Ah, I see. So you can have multiple global scopes
nhiroki
2017/04/12 08:54:45
Yes!
|
+ |
+ // Default task runner of the underlying thread. Tasks posted to this task |
+ // runner will run even after the global scope is closed. This must be used |
+ // only for control tasks. |
+ RefPtr<WebTaskRunner> m_threadControlTaskRunner; |
kinuko
2017/04/10 06:30:06
It feels a little confusing to have this and worke
nhiroki
2017/04/11 10:47:54
For now, I cannot come up with an idea to clean it
|
+ |
// This lock protects |m_globalScope|, |m_requestedToTerminate|, |
// |m_threadState|, |m_runningDebuggerTask| and |m_exitCode|. |
Mutex m_threadStateMutex; |