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 FML_WARN_UNUSED_RESULT 26 bool TryWait(); 27 28 void Signal(); 29 30 private: 31 std::unique_ptr<PlatformSemaphore> _impl; 32 33 FML_DISALLOW_COPY_AND_ASSIGN(Semaphore); 34 }; 35 36 } // namespace fml 37 38 #endif // FLUTTER_FML_SYNCHRONIZATION_SEMAPHORE_H_ 39