We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4780002 commit d0d5d42Copy full SHA for d0d5d42
1 file changed
libgo/coroutine.h
@@ -71,3 +71,21 @@ typedef ::co::CoTimer::TimerId co_timer_id;
71
#define co_last_defer() ::co::GetLastDefer()
72
#define co_defer_scope co_defer [&]
73
74
+class CountDownLatch {
75
+public:
76
+ explicit CountDownLatch(size_t n = 1) : mFlyingCount(n) {}
77
+
78
+ void Done() {
79
+ --mFlyingCount;
80
+ }
81
+ void Wait() {
82
+ while (mFlyingCount) {
83
+ co_yield;
84
85
86
+private:
87
+ size_t mFlyingCount;
88
89
+ CountDownLatch(CountDownLatch const &) = delete;
90
+ CountDownLatch& operator=(CountDownLatch const &) = delete;
91
+};
0 commit comments