1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #ifndef FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ |
6 | #define FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ |
7 | |
8 | #include <memory> |
9 | |
10 | #include "flutter/fml/compiler_specific.h" |
11 | #include "flutter/fml/macros.h" |
12 | |
13 | namespace fml { |
14 | |
15 | class PlatformSemaphore; |
16 | |
17 | class Semaphore { |
18 | public: |
19 | explicit Semaphore(uint32_t count); |
20 | |
21 | ~Semaphore(); |
22 | |
23 | bool IsValid() const; |
24 | |
25 | [[nodiscard]] bool TryWait(); |
26 | |
27 | void Signal(); |
28 | |
29 | private: |
30 | std::unique_ptr<PlatformSemaphore> _impl; |
31 | |
32 | FML_DISALLOW_COPY_AND_ASSIGN(Semaphore); |
33 | }; |
34 | |
35 | } // namespace fml |
36 | |
37 | #endif // FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ |
38 |