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

Side by Side Diff: runtime/platform/thread.h

Issue 9196002: Move Mutex and Monitor from vm/ to platform/ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef PLATFORM_THREAD_H_
6 #define PLATFORM_THREAD_H_
7
8 #include "platform/globals.h"
9
10 // Declare the OS-specific types ahead of defining the generic classes.
11 #if defined(TARGET_OS_LINUX)
12 #include "platform/thread_linux.h"
13 #elif defined(TARGET_OS_MACOS)
14 #include "platform/thread_macos.h"
15 #elif defined(TARGET_OS_WINDOWS)
16 #include "platform/thread_win.h"
17 #else
18 #error Unknown target os.
19 #endif
20
21 namespace dart {
22
Ivan Posva 2012/01/13 23:33:41 Why is class Thread not part of the header platfor
Søren Gjesse 2012/01/16 16:12:19 I was not sure we needed it but it makes sense to
23 class Mutex {
24 public:
25 Mutex();
26 ~Mutex();
27
28 void Lock();
29 bool TryLock();
30 void Unlock();
31
32 private:
33 MutexData data_;
34
35 DISALLOW_COPY_AND_ASSIGN(Mutex);
36 };
37
38
39 class Monitor {
40 public:
41 enum WaitResult {
42 kNotified,
43 kTimedOut
44 };
45
46 static const int64_t kNoTimeout = 0;
47
48 Monitor();
49 ~Monitor();
50
51 void Enter();
52 void Exit();
53
54 // Wait for notification or timeout.
55 WaitResult Wait(int64_t millis);
56
57 // Notify waiting threads.
58 void Notify();
59 void NotifyAll();
60
61 private:
62 MonitorData data_; // OS-specific data.
63
64 DISALLOW_COPY_AND_ASSIGN(Monitor);
65 };
66
67 } // namespace dart
68
69
70 #endif // PLATFORM_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698