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

Side by Side Diff: base/threading/simple_thread.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months 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 | « base/threading/simple_thread.h ('k') | base/threading/thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/threading/simple_thread.h" 5 #include "base/threading/simple_thread.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 11 matching lines...) Expand all
22 thread_(), event_(true, false), tid_(0), joined_(false) { 22 thread_(), event_(true, false), tid_(0), joined_(false) {
23 } 23 }
24 24
25 SimpleThread::~SimpleThread() { 25 SimpleThread::~SimpleThread() {
26 DCHECK(HasBeenStarted()) << "SimpleThread was never started."; 26 DCHECK(HasBeenStarted()) << "SimpleThread was never started.";
27 DCHECK(HasBeenJoined()) << "SimpleThread destroyed without being Join()ed."; 27 DCHECK(HasBeenJoined()) << "SimpleThread destroyed without being Join()ed.";
28 } 28 }
29 29
30 void SimpleThread::Start() { 30 void SimpleThread::Start() {
31 DCHECK(!HasBeenStarted()) << "Tried to Start a thread multiple times."; 31 DCHECK(!HasBeenStarted()) << "Tried to Start a thread multiple times.";
32 bool success = PlatformThread::Create(options_.stack_size(), this, &thread_); 32 bool success;
33 if (options_.priority() == ThreadPriority::NORMAL) {
34 success = PlatformThread::Create(options_.stack_size(), this, &thread_);
35 } else {
36 success = PlatformThread::CreateWithPriority(options_.stack_size(), this,
37 &thread_, options_.priority());
38 }
33 DCHECK(success); 39 DCHECK(success);
34 base::ThreadRestrictions::ScopedAllowWait allow_wait; 40 base::ThreadRestrictions::ScopedAllowWait allow_wait;
35 event_.Wait(); // Wait for the thread to complete initialization. 41 event_.Wait(); // Wait for the thread to complete initialization.
36 } 42 }
37 43
38 void SimpleThread::Join() { 44 void SimpleThread::Join() {
39 DCHECK(HasBeenStarted()) << "Tried to Join a never-started thread."; 45 DCHECK(HasBeenStarted()) << "Tried to Join a never-started thread.";
40 DCHECK(!HasBeenJoined()) << "Tried to Join a thread multiple times."; 46 DCHECK(!HasBeenJoined()) << "Tried to Join a thread multiple times.";
41 PlatformThread::Join(thread_); 47 PlatformThread::Join(thread_);
42 joined_ = true; 48 joined_ = true;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 156
151 // A NULL delegate pointer signals us to quit. 157 // A NULL delegate pointer signals us to quit.
152 if (!work) 158 if (!work)
153 break; 159 break;
154 160
155 work->Run(); 161 work->Run();
156 } 162 }
157 } 163 }
158 164
159 } // namespace base 165 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/simple_thread.h ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698