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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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/sequenced_worker_pool_unittest.cc ('k') | base/threading/thread.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_THREADING_THREAD_H_ 5 #ifndef BASE_THREADING_THREAD_H_
6 #define BASE_THREADING_THREAD_H_ 6 #define BASE_THREADING_THREAD_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/base_export.h" 13 #include "base/base_export.h"
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/message_loop/timer_slack.h" 17 #include "base/message_loop/timer_slack.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
21 #include "base/threading/platform_thread.h" 21 #include "base/threading/platform_thread.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 23
24 namespace base { 24 namespace base {
25 25
26 class MessagePump; 26 class MessagePump;
27 27
28 // A simple thread abstraction that establishes a MessageLoop on a new thread. 28 // A simple thread abstraction that establishes a MessageLoop on a new thread.
29 // The consumer uses the MessageLoop of the thread to cause code to execute on 29 // The consumer uses the MessageLoop of the thread to cause code to execute on
30 // the thread. When this object is destroyed the thread is terminated. All 30 // the thread. When this object is destroyed the thread is terminated. All
31 // pending tasks queued on the thread's message loop will run to completion 31 // pending tasks queued on the thread's message loop will run to completion
32 // before the thread is terminated. 32 // before the thread is terminated.
33 // 33 //
34 // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). 34 // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread().
35 // 35 //
36 // After the thread is stopped, the destruction sequence is: 36 // After the thread is stopped, the destruction sequence is:
37 // 37 //
38 // (1) Thread::CleanUp() 38 // (1) Thread::CleanUp()
39 // (2) MessageLoop::~MessageLoop 39 // (2) MessageLoop::~MessageLoop
40 // (3.b) MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop 40 // (3.b) MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop
41 class BASE_EXPORT Thread : PlatformThread::Delegate { 41 class BASE_EXPORT Thread : PlatformThread::Delegate {
42 public: 42 public:
43 struct BASE_EXPORT Options { 43 struct BASE_EXPORT Options {
44 typedef Callback<scoped_ptr<MessagePump>()> MessagePumpFactory; 44 typedef Callback<std::unique_ptr<MessagePump>()> MessagePumpFactory;
45 45
46 Options(); 46 Options();
47 Options(MessageLoop::Type type, size_t size); 47 Options(MessageLoop::Type type, size_t size);
48 Options(const Options& other); 48 Options(const Options& other);
49 ~Options(); 49 ~Options();
50 50
51 // Specifies the type of message loop that will be allocated on the thread. 51 // Specifies the type of message loop that will be allocated on the thread.
52 // This is ignored if message_pump_factory.is_null() is false. 52 // This is ignored if message_pump_factory.is_null() is false.
53 MessageLoop::Type message_loop_type; 53 MessageLoop::Type message_loop_type;
54 54
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 mutable WaitableEvent start_event_; 253 mutable WaitableEvent start_event_;
254 254
255 friend void ThreadQuitHelper(); 255 friend void ThreadQuitHelper();
256 256
257 DISALLOW_COPY_AND_ASSIGN(Thread); 257 DISALLOW_COPY_AND_ASSIGN(Thread);
258 }; 258 };
259 259
260 } // namespace base 260 } // namespace base
261 261
262 #endif // BASE_THREADING_THREAD_H_ 262 #endif // BASE_THREADING_THREAD_H_
OLDNEW
« no previous file with comments | « base/threading/sequenced_worker_pool_unittest.cc ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698