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

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

Issue 2218983003: Force non-joinable SimpleThreads to be leaked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f1_eatsecondparam_expectdcheckdeath
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // WARNING: You should probably be using Thread (thread.h) instead. Thread is 5 // WARNING: You should probably be using Thread (thread.h) instead. Thread is
6 // Chrome's message-loop based Thread abstraction, and if you are a 6 // Chrome's message-loop based Thread abstraction, and if you are a
7 // thread running in the browser, there will likely be assumptions 7 // thread running in the browser, there will likely be assumptions
8 // that your thread will have an associated message loop. 8 // that your thread will have an associated message loop.
9 // 9 //
10 // This is a simple thread interface that backs to a native operating system 10 // This is a simple thread interface that backs to a native operating system
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // Allow copies. 68 // Allow copies.
69 Options(const Options& other) = default; 69 Options(const Options& other) = default;
70 Options& operator=(const Options& other) = default; 70 Options& operator=(const Options& other) = default;
71 71
72 // A custom stack size, or 0 for the system default. 72 // A custom stack size, or 0 for the system default.
73 size_t stack_size = 0; 73 size_t stack_size = 0;
74 74
75 ThreadPriority priority = ThreadPriority::NORMAL; 75 ThreadPriority priority = ThreadPriority::NORMAL;
76 76
77 // If false, the thread's PlatformThreadHandle will not be kept around and 77 // If false, the underlying thread's PlatformThreadHandle will not be kept
78 // the SimpleThread instance will not be required to be Join()'ed before 78 // around and as such the SimpleThread instance will not be Join()able and
79 // being destroyed 79 // will have to be leaked. Useful for threads that want to have
80 // TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN semantics. Note: leaking a
81 // joinable thread would effictively have the same semantics, but making it
82 // non-joinable is cleaner as not keeping the PlatformThreadHandle around
83 // has the advantage of letting the system release resources associated with
84 // the thread immediately when it returns from ThreadMain().
80 bool joinable = true; 85 bool joinable = true;
81 }; 86 };
82 87
83 // Create a SimpleThread. |options| should be used to manage any specific 88 // Create a SimpleThread. |options| should be used to manage any specific
84 // configuration involving the thread creation and management. 89 // configuration involving the thread creation and management.
85 // Every thread has a name, in the form of |name_prefix|/TID, for example 90 // Every thread has a name, in the form of |name_prefix|/TID, for example
86 // "my_thread/321". The thread will not be created until Start() is called. 91 // "my_thread/321". The thread will not be created until Start() is called.
87 explicit SimpleThread(const std::string& name_prefix); 92 explicit SimpleThread(const std::string& name_prefix);
88 SimpleThread(const std::string& name_prefix, const Options& options); 93 SimpleThread(const std::string& name_prefix, const Options& options);
89 94
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 std::queue<Delegate*> delegates_; 196 std::queue<Delegate*> delegates_;
192 base::Lock lock_; // Locks delegates_ 197 base::Lock lock_; // Locks delegates_
193 WaitableEvent dry_; // Not signaled when there is no work to do. 198 WaitableEvent dry_; // Not signaled when there is no work to do.
194 199
195 DISALLOW_COPY_AND_ASSIGN(DelegateSimpleThreadPool); 200 DISALLOW_COPY_AND_ASSIGN(DelegateSimpleThreadPool);
196 }; 201 };
197 202
198 } // namespace base 203 } // namespace base
199 204
200 #endif // BASE_THREADING_SIMPLE_THREAD_H_ 205 #endif // BASE_THREADING_SIMPLE_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/simple_thread.cc » ('j') | base/threading/simple_thread_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698