OLD | NEW |
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 *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 #pragma once | 11 #pragma once |
12 | 12 |
13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/time.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 | 17 |
17 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
18 #include <windows.h> | 19 #include <windows.h> |
19 #elif defined(OS_POSIX) | 20 #elif defined(OS_POSIX) |
20 #include <pthread.h> | 21 #include <pthread.h> |
21 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
22 #include <mach/mach.h> | 23 #include <mach/mach.h> |
23 #else // OS_POSIX && !OS_MACOSX | 24 #else // OS_POSIX && !OS_MACOSX |
24 #include <unistd.h> | 25 #include <unistd.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 // Gets the current thread id, which may be useful for logging purposes. | 69 // Gets the current thread id, which may be useful for logging purposes. |
69 static PlatformThreadId CurrentId(); | 70 static PlatformThreadId CurrentId(); |
70 | 71 |
71 // Yield the current thread so another thread can be scheduled. | 72 // Yield the current thread so another thread can be scheduled. |
72 static void YieldCurrentThread(); | 73 static void YieldCurrentThread(); |
73 | 74 |
74 // Sleeps for the specified duration (units are milliseconds). | 75 // Sleeps for the specified duration (units are milliseconds). |
75 static void Sleep(int duration_ms); | 76 static void Sleep(int duration_ms); |
76 | 77 |
| 78 // Sleeps for the specified duration. |
| 79 static void Sleep(base::TimeDelta duration); |
| 80 |
77 // Sets the thread name visible to debuggers/tools. This has no effect | 81 // Sets the thread name visible to debuggers/tools. This has no effect |
78 // otherwise. This name pointer is not copied internally. Thus, it must stay | 82 // otherwise. This name pointer is not copied internally. Thus, it must stay |
79 // valid until the thread ends. | 83 // valid until the thread ends. |
80 static void SetName(const char* name); | 84 static void SetName(const char* name); |
81 | 85 |
82 // Gets the thread name, if previously set by SetName. | 86 // Gets the thread name, if previously set by SetName. |
83 static const char* GetName(); | 87 static const char* GetName(); |
84 | 88 |
85 // Creates a new thread. The |stack_size| parameter can be 0 to indicate | 89 // Creates a new thread. The |stack_size| parameter can be 0 to indicate |
86 // that the default stack size should be used. Upon success, | 90 // that the default stack size should be used. Upon success, |
(...skipping 19 matching lines...) Expand all Loading... |
106 static void SetThreadPriority(PlatformThreadHandle handle, | 110 static void SetThreadPriority(PlatformThreadHandle handle, |
107 ThreadPriority priority); | 111 ThreadPriority priority); |
108 | 112 |
109 private: | 113 private: |
110 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); | 114 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread); |
111 }; | 115 }; |
112 | 116 |
113 } // namespace base | 117 } // namespace base |
114 | 118 |
115 #endif // BASE_THREADING_PLATFORM_THREAD_H_ | 119 #endif // BASE_THREADING_PLATFORM_THREAD_H_ |
OLD | NEW |