Lines Matching refs:Worker
227 // Worker ---------------------------------------------------------------------
229 class SequencedWorkerPool::Worker : public SimpleThread {
233 Worker(const scoped_refptr<SequencedWorkerPool>& worker_pool,
236 ~Worker() override;
241 // Gets the worker for the current thread out of thread-local storage.
242 static Worker* GetForCurrentThread();
256 // Whether the worker is processing a task.
274 static LazyInstance<ThreadLocalPointer<SequencedWorkerPool::Worker>>::Leaky
284 // Whether the Worker is processing a task.
287 DISALLOW_COPY_AND_ASSIGN(Worker);
294 // Take a raw pointer to |worker| to avoid cycles (since we're owned
335 // Runs the worker loop on the background thread.
336 void ThreadLoop(Worker* this_worker);
432 // Condition variable that is waited on by worker threads until new
436 // Condition variable that is waited on by non-worker threads (in
440 // The maximum number of worker threads we'll create.
451 typedef std::map<PlatformThreadId, linked_ptr<Worker> > ThreadMap;
504 // Worker definitions ---------------------------------------------------------
506 SequencedWorkerPool::Worker::Worker(
510 : SimpleThread(prefix + StringPrintf("Worker%d", thread_number)),
517 SequencedWorkerPool::Worker::~Worker() {
520 void SequencedWorkerPool::Worker::Run() {
525 // Store a pointer to this worker in thread local storage for static function
533 // having these worker objects at all, but that method lacks the ability to
541 SequencedWorkerPool::Worker*
542 SequencedWorkerPool::Worker::GetForCurrentThread() {
551 LazyInstance<ThreadLocalPointer<SequencedWorkerPool::Worker>>::Leaky
552 SequencedWorkerPool::Worker::lazy_tls_ptr_ = LAZY_INSTANCE_INITIALIZER;
786 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 thread is cleaning up, we idle here until thats done.
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).