Skip to content

Commit c9b7ad5

Browse files
authored
set default behaviour for bthread_cond_signal to no signal (#7)
1 parent 62a3c88 commit c9b7ad5

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

src/bthread/bthread.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,8 @@ extern int bthread_cond_init(bthread_cond_t* __restrict cond,
196196
// Destroy condition variable `cond'.
197197
extern int bthread_cond_destroy(bthread_cond_t* cond);
198198

199-
#ifndef BTHREAD_COND_SIGNAL
200-
#define BTHREAD_COND_SIGNAL
201199
// Wake up one thread waiting for condition variable `cond'.
202-
extern int bthread_cond_signal(bthread_cond_t* cond, bool no_signal = false);
203-
#endif
200+
extern int bthread_cond_signal(bthread_cond_t* cond);
204201

205202
// Wake up all threads waiting for condition variables `cond'.
206203
extern int bthread_cond_broadcast(bthread_cond_t* cond);

src/bthread/condition_variable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ int bthread_cond_destroy(bthread_cond_t* c) {
5858
return 0;
5959
}
6060

61-
int bthread_cond_signal(bthread_cond_t* c, bool no_signal) {
61+
int bthread_cond_signal(bthread_cond_t* c) {
6262
bthread::CondInternal* ic = reinterpret_cast<bthread::CondInternal*>(c);
6363
// ic is probably dereferenced after fetch_add, save required fields before
6464
// this point
6565
butil::atomic<int>* const saved_seq = ic->seq;
6666
saved_seq->fetch_add(1, butil::memory_order_release);
6767
// don't touch ic any more
68+
bool no_signal = true;
6869
bthread::butex_wake(saved_seq, no_signal);
6970
return 0;
7071
}

src/bthread/condition_variable.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ __BEGIN_DECLS
2929
extern int bthread_cond_init(bthread_cond_t* __restrict cond,
3030
const bthread_condattr_t* __restrict cond_attr);
3131
extern int bthread_cond_destroy(bthread_cond_t* cond);
32-
#ifndef BTHREAD_COND_SIGNAL
33-
#define BTHREAD_COND_SIGNAL
34-
extern int bthread_cond_signal(bthread_cond_t* cond, bool no_signal = false);
35-
#endif
32+
extern int bthread_cond_signal(bthread_cond_t* cond);
3633
extern int bthread_cond_broadcast(bthread_cond_t* cond);
3734
extern int bthread_cond_wait(bthread_cond_t* __restrict cond,
3835
bthread_mutex_t* __restrict mutex);
@@ -92,8 +89,8 @@ class ConditionVariable {
9289
return rc == ETIMEDOUT ? ETIMEDOUT : 0;
9390
}
9491

95-
void notify_one(bool no_signal = false) {
96-
bthread_cond_signal(&_cond, no_signal);
92+
void notify_one() {
93+
bthread_cond_signal(&_cond);
9794
}
9895

9996
void notify_all() {

0 commit comments

Comments
 (0)