Skip to content

Commit

Permalink
Support noncopyable sync objects
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright committed Sep 17, 2024
1 parent 9643150 commit 734874a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/bthread/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define BTHREAD_TYPES_H

#include <stdint.h> // uint64_t
#include "butil/macros.h"
#if defined(__cplusplus)
#include "butil/logging.h" // CHECK
#endif
Expand Down Expand Up @@ -164,15 +165,23 @@ typedef struct {
size_t sampling_range;
} bthread_contention_site_t;

typedef struct {
typedef struct bthread_mutex_t {
#if defined(__cplusplus) && defined(NONCOPIABLE_SYNC_OBJECT)
bthread_mutex_t() : butex(NULL), csite{} {}
DISALLOW_COPY_AND_ASSIGN(bthread_mutex_t);
#endif
unsigned* butex;
bthread_contention_site_t csite;
} bthread_mutex_t;

typedef struct {
} bthread_mutexattr_t;

typedef struct {
typedef struct bthread_cond_t {
#if defined(__cplusplus) && defined(NONCOPIABLE_SYNC_OBJECT)
bthread_cond_t() : m(NULL), seq(NULL) {}
DISALLOW_COPY_AND_ASSIGN(bthread_cond_t);
#endif
bthread_mutex_t* m;
int* seq;
} bthread_cond_t;
Expand Down Expand Up @@ -208,8 +217,10 @@ friend int bthread::bthread_once_impl(bthread_once_t* once_control, void (*init_
INITIALIZED,
};


bthread_once_t();
~bthread_once_t();
DISALLOW_COPY_AND_ASSIGN(bthread_once_t);

private:
butil::atomic<int>* _butex;
Expand Down

0 comments on commit 734874a

Please sign in to comment.