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#include "flutter/fml/synchronization/count_down_latch.h"
6
7#include "flutter/fml/logging.h"
8
9namespace fml {
10
11CountDownLatch::CountDownLatch(size_t count) : count_(count) {
12 if (count_ == 0) {
13 waitable_event_.Signal();
14 }
15}
16
17CountDownLatch::~CountDownLatch() = default;
18
19void CountDownLatch::Wait() {
20 waitable_event_.Wait();
21}
22
23void CountDownLatch::CountDown() {
24 if (--count_ == 0) {
25 waitable_event_.Signal();
26 }
27}
28
29} // namespace fml
30