Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/bthread/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,26 @@ typedef struct bthread_cond_t {
typedef struct {
} bthread_condattr_t;

typedef struct {
typedef struct bthread_sem_t {
#if defined(__cplusplus)
bthread_sem_t() : butex(NULL), enable_csite(true) {}
DISALLOW_COPY_AND_ASSIGN(bthread_sem_t);
#endif
unsigned* butex;
bool enable_csite;
} bthread_sem_t;

typedef struct {
typedef struct bthread_rwlock_t {
#if defined(__cplusplus)
bthread_rwlock_t()
: reader_count(0), reader_wait(0), wlock_flag(false), writer_csite{} {}
DISALLOW_COPY_AND_ASSIGN(bthread_rwlock_t);
#endif
bthread_sem_t reader_sema; // Semaphore for readers to wait for completing writers.
bthread_sem_t writer_sema; // Semaphore for writers to wait for completing readers.
int reader_count; // Number of pending readers.
int reader_wait; // Number of departing readers.
bool wlock_flag; // Flag used to indicate that a write lock has been hold.
bool wlock_flag; // Flag used to indicate that a write lock has been held.
bthread_mutex_t write_queue_mutex; // Held if there are pending writers.
bthread_contention_site_t writer_csite;
} bthread_rwlock_t;
Expand Down
1 change: 1 addition & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ TEST_BUTIL_SOURCES = [
#"popen_unittest.cpp",
"bounded_queue_unittest.cc",
"butil_unittest_main.cpp",
"scope_guard_unittest.cc",
] + select({
"@bazel_tools//tools/osx:darwin_x86_64": [],
"//conditions:default": [
Expand Down