File tree Expand file tree Collapse file tree 4 files changed +60
-39
lines changed Expand file tree Collapse file tree 4 files changed +60
-39
lines changed Original file line number Diff line number Diff line change 16
16
#include < utility>
17
17
18
18
#include " bin/builtin.h"
19
+ #include " bin/lockers.h"
19
20
#include " bin/reference_counting.h"
20
21
#include " bin/socket_base.h"
21
22
#include " bin/thread.h"
@@ -29,7 +30,6 @@ class EventHandlerImplementation;
29
30
class FileHandle ;
30
31
class Handle ;
31
32
class ListenSocket ;
32
- class MonitorLocker ;
33
33
class SocketHandle ;
34
34
35
35
// An OverlappedBuffer encapsulates the OVERLAPPED structure and the
Original file line number Diff line number Diff line change 5
5
#ifndef RUNTIME_BIN_LOCKERS_H_
6
6
#define RUNTIME_BIN_LOCKERS_H_
7
7
8
- #include " bin/thread.h"
9
8
#include " platform/assert.h"
9
+ #include " platform/lockers.h"
10
10
11
11
namespace dart {
12
12
namespace bin {
13
13
14
- class MutexLocker {
15
- public:
16
- explicit MutexLocker (Mutex* mutex) : mutex_(mutex) {
17
- ASSERT (mutex != nullptr );
18
- mutex_->Lock ();
19
- }
20
-
21
- virtual ~MutexLocker () { mutex_->Unlock (); }
22
-
23
- private:
24
- Mutex* const mutex_;
25
-
26
- DISALLOW_COPY_AND_ASSIGN (MutexLocker);
27
- };
28
-
29
- class MonitorLocker {
30
- public:
31
- explicit MonitorLocker (Monitor* monitor) : monitor_(monitor) {
32
- ASSERT (monitor != nullptr );
33
- monitor_->Enter ();
34
- }
35
-
36
- virtual ~MonitorLocker () { monitor_->Exit (); }
37
-
38
- Monitor::WaitResult Wait (int64_t millis = Monitor::kNoTimeout ) {
39
- return monitor_->Wait (millis);
40
- }
41
-
42
- void Notify () { monitor_->Notify (); }
43
-
44
- void NotifyAll () { monitor_->NotifyAll (); }
45
-
46
- private:
47
- Monitor* const monitor_;
48
-
49
- DISALLOW_COPY_AND_ASSIGN (MonitorLocker);
50
- };
14
+ using MutexLocker = dart::platform::MutexLocker;
15
+ using MonitorLocker = dart::platform::MonitorLocker;
51
16
52
17
} // namespace bin
53
18
} // namespace dart
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2025, 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 RUNTIME_PLATFORM_LOCKERS_H_
6
+ #define RUNTIME_PLATFORM_LOCKERS_H_
7
+
8
+ #include " platform/assert.h"
9
+ #include " platform/synchronization.h"
10
+
11
+ namespace dart {
12
+ namespace platform {
13
+
14
+ class MutexLocker {
15
+ public:
16
+ explicit MutexLocker (Mutex* mutex) : mutex_(mutex) {
17
+ ASSERT (mutex != nullptr );
18
+ mutex_->Lock ();
19
+ }
20
+
21
+ virtual ~MutexLocker () { mutex_->Unlock (); }
22
+
23
+ private:
24
+ Mutex* const mutex_;
25
+
26
+ DISALLOW_COPY_AND_ASSIGN (MutexLocker);
27
+ };
28
+
29
+ class MonitorLocker {
30
+ public:
31
+ explicit MonitorLocker (Monitor* monitor) : monitor_(monitor) {
32
+ ASSERT (monitor != nullptr );
33
+ monitor_->Enter ();
34
+ }
35
+
36
+ virtual ~MonitorLocker () { monitor_->Exit (); }
37
+
38
+ Monitor::WaitResult Wait (int64_t millis = Monitor::kNoTimeout ) {
39
+ return monitor_->Wait (millis);
40
+ }
41
+
42
+ void Notify () { monitor_->Notify (); }
43
+
44
+ void NotifyAll () { monitor_->NotifyAll (); }
45
+
46
+ private:
47
+ Monitor* const monitor_;
48
+
49
+ DISALLOW_COPY_AND_ASSIGN (MonitorLocker);
50
+ };
51
+
52
+ } // namespace platform
53
+ } // namespace dart
54
+
55
+ #endif // RUNTIME_PLATFORM_LOCKERS_H_
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ platform_sources = [
18
18
" growable_array.h" ,
19
19
" hashmap.cc" ,
20
20
" hashmap.h" ,
21
+ " lockers.h" ,
21
22
" memory_sanitizer.h" ,
22
23
" safe_stack.h" ,
23
24
" signal_blocker.h" ,
You can’t perform that action at this time.
0 commit comments