aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils/SkCountdown.h
blob: 6bcec7d5ff921efabb3c52c0593218498d523c88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkCountdown_DEFINED
#define SkCountdown_DEFINED

#include "SkCondVar.h"
#include "SkRunnable.h"
#include "SkTypes.h"

class SkCountdown : public SkRunnable {
public:
    explicit SkCountdown(int32_t count);

    /**
     * Resets the countdown to the count provided.
     */
    void reset(int32_t count);

    virtual void run() SK_OVERRIDE;

    /**
     * Blocks until run() has been called count times.
     */
    void wait();

private:
    SkCondVar fReady;
    int32_t   fCount;
};

#endif