Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9c17123

Browse files
committed
Replace EVent with fml::AutoResetWaitableEvent
1 parent 5957c7b commit 9c17123

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.mm

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h"
2+
#import "fml/synchronization/waitable_event.h"
23

34
#import <QuartzCore/QuartzCore.h>
45
#include <mutex>
@@ -17,31 +18,6 @@ @interface FlutterThreadSynchronizer () {
1718

1819
@end
1920

20-
namespace {
21-
/// Single use event (can only be signalled once).
22-
class Event {
23-
public:
24-
void Signal() {
25-
assert(!signaled_);
26-
std::scoped_lock locker(mutex_);
27-
signaled_ = true;
28-
cv_.notify_one();
29-
}
30-
31-
void Wait() {
32-
std::unique_lock<std::mutex> locker(mutex_);
33-
while (!signaled_) {
34-
cv_.wait(locker);
35-
}
36-
}
37-
38-
private:
39-
std::condition_variable cv_;
40-
std::mutex mutex_;
41-
bool signaled_ = false;
42-
};
43-
} // namespace
44-
4521
@implementation FlutterThreadSynchronizer
4622

4723
- (void)drain {
@@ -101,10 +77,10 @@ - (void)beginResize:(CGSize)size notify:(nonnull dispatch_block_t)notify {
10177
}
10278

10379
- (void)performCommit:(CGSize)size notify:(nonnull dispatch_block_t)notify {
104-
Event event;
80+
fml::AutoResetWaitableEvent event;
10581
{
10682
std::unique_lock<std::mutex> lock(_mutex);
107-
Event& e = event;
83+
fml::AutoResetWaitableEvent& e = event;
10884
_scheduledBlocks.push_back(^{
10985
notify();
11086
_contentSize = size;

0 commit comments

Comments
 (0)