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 1616#include < utility>
1717
1818#include " bin/builtin.h"
19+ #include " bin/lockers.h"
1920#include " bin/reference_counting.h"
2021#include " bin/socket_base.h"
2122#include " bin/thread.h"
@@ -29,7 +30,6 @@ class EventHandlerImplementation;
2930class FileHandle ;
3031class Handle ;
3132class ListenSocket ;
32- class MonitorLocker ;
3333class SocketHandle ;
3434
3535// An OverlappedBuffer encapsulates the OVERLAPPED structure and the
Original file line number Diff line number Diff line change 55#ifndef RUNTIME_BIN_LOCKERS_H_
66#define RUNTIME_BIN_LOCKERS_H_
77
8- #include " bin/thread.h"
98#include " platform/assert.h"
9+ #include " platform/lockers.h"
1010
1111namespace dart {
1212namespace bin {
1313
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;
5116
5217} // namespace bin
5318} // 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 = [
1818 " growable_array.h" ,
1919 " hashmap.cc" ,
2020 " hashmap.h" ,
21+ " lockers.h" ,
2122 " memory_sanitizer.h" ,
2223 " safe_stack.h" ,
2324 " signal_blocker.h" ,
You can’t perform that action at this time.
0 commit comments