add function sf_synchronize_counter_notify
parent
b9b466c364
commit
255754eb5f
|
|
@ -76,6 +76,14 @@ static inline int sf_synchronize_ctx_init(SFSynchronizeContext *sctx)
|
||||||
return init_pthread_lock_cond_pair(&sctx->lcp);
|
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)
|
static inline void sf_synchronize_counter_wait(SFSynchronizeContext *sctx)
|
||||||
{
|
{
|
||||||
PTHREAD_MUTEX_LOCK(&sctx->lcp.lock);
|
PTHREAD_MUTEX_LOCK(&sctx->lcp.lock);
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ typedef struct sf_cluster_config {
|
||||||
typedef struct sf_synchronize_context {
|
typedef struct sf_synchronize_context {
|
||||||
pthread_lock_cond_pair_t lcp;
|
pthread_lock_cond_pair_t lcp;
|
||||||
union {
|
union {
|
||||||
bool done;
|
bool finished;
|
||||||
int result;
|
int result;
|
||||||
volatile int waiting_count;
|
volatile int waiting_count;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue