add function sf_synchronize_counter_notify

storage_engine
YuQing 2021-10-28 16:19:02 +08:00
parent b9b466c364
commit 255754eb5f
2 changed files with 9 additions and 1 deletions

View File

@ -76,6 +76,14 @@ static inline int sf_synchronize_ctx_init(SFSynchronizeContext *sctx)
return init_pthread_lock_cond_pair(&sctx->lcp);
}
static inline void sf_synchronize_counter_notify(SFSynchronizeContext *sctx,
const int count)
{
if (__sync_sub_and_fetch(&sctx->waiting_count, count) == 0) {
pthread_cond_signal(&sctx->lcp.cond);
}
}
static inline void sf_synchronize_counter_wait(SFSynchronizeContext *sctx)
{
PTHREAD_MUTEX_LOCK(&sctx->lcp.lock);

View File

@ -238,7 +238,7 @@ typedef struct sf_cluster_config {
typedef struct sf_synchronize_context {
pthread_lock_cond_pair_t lcp;
union {
bool done;
bool finished;
int result;
volatile int waiting_count;
};