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

Side by Side Diff: mojo/public/cpp/utility/thread.h

Issue 1784643002: Mojo C++ bindings: remove the utility/ folder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@13_1_remove_thread_dep
Patch Set: Created 4 years, 9 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 | « mojo/public/cpp/utility/tests/thread_unittest.cc ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_CPP_UTILITY_THREAD_H_
6 #define MOJO_PUBLIC_CPP_UTILITY_THREAD_H_
7
8 #ifdef _WIN32
9 #error "Not implemented: See crbug.com/342893."
10 #endif
11
12 #include <pthread.h>
13 #include <stddef.h>
14
15 #include "base/macros.h"
16
17 namespace mojo {
18
19 // This class is thread-friendly, not thread-safe (e.g., you mustn't call
20 // |Join()| from multiple threads and/or simultaneously try to destroy the
21 // object).
22 class Thread {
23 public:
24 // TODO(vtl): Support non-joinable? priority?
25 class Options {
26 public:
27 Options() : stack_size_(0) {}
28
29 // A stack size of 0 means the default.
30 size_t stack_size() const { return stack_size_; }
31 void set_stack_size(size_t stack_size) { stack_size_ = stack_size; }
32
33 private:
34 size_t stack_size_;
35
36 // Copy and assign allowed.
37 };
38
39 // TODO(vtl): Add name or name prefix?
40 Thread();
41 explicit Thread(const Options& options);
42 virtual ~Thread();
43
44 void Start();
45 void Join();
46
47 virtual void Run() = 0;
48
49 private:
50 static void* ThreadRunTrampoline(void* arg);
51
52 const Options options_;
53 pthread_t thread_;
54 bool started_;
55 bool joined_;
56
57 DISALLOW_COPY_AND_ASSIGN(Thread);
58 };
59
60 } // namespace mojo
61
62 #endif // MOJO_PUBLIC_CPP_UTILITY_THREAD_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/utility/tests/thread_unittest.cc ('k') | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698