diff -r 000000000000 -r 6474c204b198 gfx/skia/trunk/src/utils/SkCountdown.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx/skia/trunk/src/utils/SkCountdown.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkCountdown.h" +#include "SkThread.h" + +SkCountdown::SkCountdown(int32_t count) +: fCount(count) {} + +void SkCountdown::reset(int32_t count) { + fCount = count; +} + +void SkCountdown::run() { + if (sk_atomic_dec(&fCount) == 1) { + fReady.lock(); + fReady.signal(); + fReady.unlock(); + } +} + +void SkCountdown::wait() { + fReady.lock(); + while (fCount > 0) { + fReady.wait(); + } + fReady.unlock(); +}