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_COUNT_DOWN_LATCH_H_ 6 #define FLUTTER_FML_SYNCHRONIZATION_COUNT_DOWN_LATCH_H_ 7 8 #include <atomic> 9 10 #include "flutter/fml/macros.h" 11 #include "flutter/fml/synchronization/waitable_event.h" 12 13 namespace fml { 14 15 class CountDownLatch { 16 public: 17 CountDownLatch(size_t count); 18 19 ~CountDownLatch(); 20 21 void Wait(); 22 23 void CountDown(); 24 25 private: 26 std::atomic_size_t count_; 27 ManualResetWaitableEvent waitable_event_; 28 29 FML_DISALLOW_COPY_AND_ASSIGN(CountDownLatch); 30 }; 31 32 } // namespace fml 33 34 #endif // FLUTTER_FML_SYNCHRONIZATION_COUNT_DOWN_LATCH_H_ 35