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

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

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 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 | « base/test/test_timeouts.cc ('k') | base/threading/platform_thread_unittest.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 // WARNING: You should *NOT* be using this class directly. PlatformThread is 5 // WARNING: You should *NOT* be using this class directly. PlatformThread is
6 // the low-level platform-specific abstraction to the OS's threading interface. 6 // the low-level platform-specific abstraction to the OS's threading interface.
7 // You should instead be using a message-loop driven Thread, see thread.h. 7 // You should instead be using a message-loop driven Thread, see thread.h.
8 8
9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_ 9 #ifndef BASE_THREADING_PLATFORM_THREAD_H_
10 #define BASE_THREADING_PLATFORM_THREAD_H_ 10 #define BASE_THREADING_PLATFORM_THREAD_H_
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_POSIX)
18 #include <windows.h>
19 #elif defined(OS_POSIX)
20 #include <pthread.h> 18 #include <pthread.h>
21 #include <unistd.h> 19 #include <unistd.h>
22 #endif 20 #endif
23 21
24 namespace base { 22 namespace base {
25 23
26 // Used for logging. Always an integer value. 24 // Used for logging. Always an integer value.
27 #if defined(OS_WIN) 25 #if defined(OS_POSIX)
28 typedef DWORD PlatformThreadId;
29 #elif defined(OS_POSIX)
30 typedef pid_t PlatformThreadId; 26 typedef pid_t PlatformThreadId;
31 #endif 27 #endif
32 28
33 // Used for thread checking and debugging. 29 // Used for thread checking and debugging.
34 // Meant to be as fast as possible. 30 // Meant to be as fast as possible.
35 // These are produced by PlatformThread::CurrentRef(), and used to later 31 // These are produced by PlatformThread::CurrentRef(), and used to later
36 // check if we are on the same thread or not by using ==. These are safe 32 // check if we are on the same thread or not by using ==. These are safe
37 // to copy between threads, but can't be copied to another process as they 33 // to copy between threads, but can't be copied to another process as they
38 // have no meaning there. Also, the internal identifier can be re-used 34 // have no meaning there. Also, the internal identifier can be re-used
39 // after a thread dies, so a PlatformThreadRef cannot be reliably used 35 // after a thread dies, so a PlatformThreadRef cannot be reliably used
40 // to distinguish a new thread from an old, dead thread. 36 // to distinguish a new thread from an old, dead thread.
41 class PlatformThreadRef { 37 class PlatformThreadRef {
42 public: 38 public:
43 #if defined(OS_WIN) 39 #if defined(OS_POSIX)
44 typedef DWORD RefType;
45 #elif defined(OS_POSIX)
46 typedef pthread_t RefType; 40 typedef pthread_t RefType;
47 #endif 41 #endif
48 PlatformThreadRef() 42 PlatformThreadRef()
49 : id_(0) { 43 : id_(0) {
50 } 44 }
51 45
52 explicit PlatformThreadRef(RefType id) 46 explicit PlatformThreadRef(RefType id)
53 : id_(id) { 47 : id_(id) {
54 } 48 }
55 49
56 bool operator==(PlatformThreadRef other) const { 50 bool operator==(PlatformThreadRef other) const {
57 return id_ == other.id_; 51 return id_ == other.id_;
58 } 52 }
59 53
60 bool is_null() const { 54 bool is_null() const {
61 return id_ == 0; 55 return id_ == 0;
62 } 56 }
63 private: 57 private:
64 RefType id_; 58 RefType id_;
65 }; 59 };
66 60
67 // Used to operate on threads. 61 // Used to operate on threads.
68 class PlatformThreadHandle { 62 class PlatformThreadHandle {
69 public: 63 public:
70 #if defined(OS_WIN) 64 #if defined(OS_POSIX)
71 typedef void* Handle;
72 #elif defined(OS_POSIX)
73 typedef pthread_t Handle; 65 typedef pthread_t Handle;
74 #endif 66 #endif
75 67
76 PlatformThreadHandle() 68 PlatformThreadHandle()
77 : handle_(0), 69 : handle_(0),
78 id_(0) { 70 id_(0) {
79 } 71 }
80 72
81 explicit PlatformThreadHandle(Handle handle) 73 explicit PlatformThreadHandle(Handle handle)
82 : handle_(handle), 74 : handle_(handle),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 194
203 static ThreadPriority GetThreadPriority(PlatformThreadHandle handle); 195 static ThreadPriority GetThreadPriority(PlatformThreadHandle handle);
204 196
205 private: 197 private:
206 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); 198 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread);
207 }; 199 };
208 200
209 } // namespace base 201 } // namespace base
210 202
211 #endif // BASE_THREADING_PLATFORM_THREAD_H_ 203 #endif // BASE_THREADING_PLATFORM_THREAD_H_
OLDNEW
« no previous file with comments | « base/test/test_timeouts.cc ('k') | base/threading/platform_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698