Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: base/task_scheduler/scheduler_worker.cc

Issue 2435013006: [TaskScheduler] Temporarily co-init all TaskScheduler threads to match SequencedWorkerPool's behavi… (Closed)
Patch Set: outside while loop Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/task_scheduler/scheduler_worker.h" 5 #include "base/task_scheduler/scheduler_worker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/task_scheduler/task_tracker.h" 14 #include "base/task_scheduler/task_tracker.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 16
17 #if defined(OS_MACOSX) 17 #if defined(OS_MACOSX)
18 #include "base/mac/scoped_nsautorelease_pool.h" 18 #include "base/mac/scoped_nsautorelease_pool.h"
19 #elif defined(OS_WIN)
20 #include "base/win/scoped_com_initializer.h"
19 #endif 21 #endif
20 22
21 namespace base { 23 namespace base {
22 namespace internal { 24 namespace internal {
23 25
24 class SchedulerWorker::Thread : public PlatformThread::Delegate { 26 class SchedulerWorker::Thread : public PlatformThread::Delegate {
25 public: 27 public:
26 ~Thread() override = default; 28 ~Thread() override = default;
27 29
28 static std::unique_ptr<Thread> Create(SchedulerWorker* outer) { 30 static std::unique_ptr<Thread> Create(SchedulerWorker* outer) {
(...skipping 10 matching lines...) Expand all
39 std::unique_ptr<Thread> detached_thread; 41 std::unique_ptr<Thread> detached_thread;
40 42
41 outer_->delegate_->OnMainEntry( 43 outer_->delegate_->OnMainEntry(
42 outer_, outer_->last_detach_time_.is_null() 44 outer_, outer_->last_detach_time_.is_null()
43 ? TimeDelta::Max() 45 ? TimeDelta::Max()
44 : TimeTicks::Now() - outer_->last_detach_time_); 46 : TimeTicks::Now() - outer_->last_detach_time_);
45 47
46 // A SchedulerWorker starts out waiting for work. 48 // A SchedulerWorker starts out waiting for work.
47 WaitForWork(); 49 WaitForWork();
48 50
51 #if defined(OS_WIN)
52 // This is required as SequencedWorkerPool previously blindly CoInitialized
53 // all of its threads.
54 // TODO: Get rid of this broad COM scope and force tasks that care about a
55 // CoInitialized environment to request one (via an upcoming ExecutionMode).
56 win::ScopedCOMInitializer com_initializer;
57 #endif
58
49 while (!outer_->task_tracker_->IsShutdownComplete() && 59 while (!outer_->task_tracker_->IsShutdownComplete() &&
50 !outer_->should_exit_for_testing_.IsSet()) { 60 !outer_->should_exit_for_testing_.IsSet()) {
51 DCHECK(outer_); 61 DCHECK(outer_);
52 62
53 #if defined(OS_MACOSX) 63 #if defined(OS_MACOSX)
54 mac::ScopedNSAutoreleasePool autorelease_pool; 64 mac::ScopedNSAutoreleasePool autorelease_pool;
55 #endif 65 #endif
56 66
57 UpdateThreadPriority(GetDesiredThreadPriority()); 67 UpdateThreadPriority(GetDesiredThreadPriority());
58 68
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 thread_ = Thread::Create(this); 278 thread_ = Thread::Create(this);
269 } 279 }
270 280
271 void SchedulerWorker::CreateThreadAssertSynchronized() { 281 void SchedulerWorker::CreateThreadAssertSynchronized() {
272 thread_lock_.AssertAcquired(); 282 thread_lock_.AssertAcquired();
273 CreateThread(); 283 CreateThread();
274 } 284 }
275 285
276 } // namespace internal 286 } // namespace internal
277 } // namespace base 287 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698