+struct thread_args {
+ RCPtr<VBucket> vbucket;
+ CheckpointManager *checkpoint_manager;
+ int n_threads;
+ std::string name;
+};
+
+/*
+ * atomically increment a threadCount
+ * if the calling thread is the last one up, notify_all
+ * if the calling thread is not the last one up, wait (in the function)
+ */
+static void thread_up(struct thread_args* args) {
+ static int threadCount = 0;
+ static std::mutex m;
+ static std::condition_variable cv;
+ std::unique_lock<std::mutex> lh(m);
+ if (++threadCount != args->n_threads) {
+ cv.wait(lh, [args](){return threadCount == args->n_threads;});
+ } else {
+ cv.notify_all(); // all threads accounted for, begin
+ }
+ lh.unlock();
+}
+