Lines Matching refs:Worker
226 // Worker ---------------------------------------------------------------------
228 class SequencedWorkerPool::Worker : public SimpleThread {
232 Worker(scoped_refptr<SequencedWorkerPool> worker_pool,
235 ~Worker() override;
240 // Gets the worker for the current thread out of thread-local storage.
241 static Worker* GetForCurrentThread();
255 // Whether the worker is processing a task.
273 static LazyInstance<ThreadLocalPointer<SequencedWorkerPool::Worker>>::Leaky
283 // Whether the Worker is processing a task.
286 DISALLOW_COPY_AND_ASSIGN(Worker);
293 // Take a raw pointer to |worker| to avoid cycles (since we're owned
334 // Runs the worker loop on the background thread.
335 void ThreadLoop(Worker* this_worker);
431 // Condition variable that is waited on by worker threads until new
435 // Condition variable that is waited on by non-worker threads (in
439 // The maximum number of worker threads we'll create.
450 using ThreadMap = std::map<PlatformThreadId, std::unique_ptr<Worker>>;
503 // Worker definitions ---------------------------------------------------------
505 SequencedWorkerPool::Worker::Worker(
509 : SimpleThread(prefix + StringPrintf("Worker%d", thread_number)),
516 SequencedWorkerPool::Worker::~Worker() {
519 void SequencedWorkerPool::Worker::Run() {
524 // Store a pointer to this worker in thread local storage for static function
532 // having these worker objects at all, but that method lacks the ability to
540 SequencedWorkerPool::Worker*
541 SequencedWorkerPool::Worker::GetForCurrentThread() {
550 LazyInstance<ThreadLocalPointer<SequencedWorkerPool::Worker>>::Leaky
551 SequencedWorkerPool::Worker::lazy_tls_ptr_ = LAZY_INSTANCE_INITIALIZER;
785 void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
820 // worker thread. (Technically not required, since we
875 // but only worker threads are allowed to post tasks at that time, and
916 // We noticed we should exit. Wake up the next worker so it knows it should
940 // Another worker
1004 // When a worker finishes a task of one sequence token, it can pick up the
1144 // one worker at a time, the following sequence of events can happen:
1148 // 2. The first task post causes us to start a worker. Other tasks do not
1149 // cause a worker to start since one is pending.
1180 // The worker is assigned to the list when the thread actually starts, which
1182 new Worker(worker_pool_, thread_number, thread_name_prefix_);
1212 Worker* worker = Worker::GetForCurrentThread();
1213 if (!worker)
1216 return worker->task_sequence_token();
1222 Worker* worker = Worker::GetForCurrentThread();
1223 if (!worker)
1226 return worker->worker_pool();
1232 Worker* worker = Worker::GetForCurrentThread();
1234 // If there is no worker, this thread is not a worker thread. Otherwise, it is
1236 if (!worker)
1239 scoped_refptr<SequencedWorkerPool> pool = worker->worker_pool();
1240 SequenceToken sequence_token = worker->task_sequence_token();
1241 WorkerShutdown shutdown_behavior = worker->task_shutdown_behavior();
1272 // Avoid deleting ourselves on a worker thread (which would deadlock).