Skip to content

Commit

Permalink
Merge pull request #2766 from chenBright/noncopyable_sync
Browse files Browse the repository at this point in the history
Support noncopyable sync objects
  • Loading branch information
lorinlee committed Sep 20, 2024
2 parents 9643150 + 5b770b5 commit 8fa216c
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)
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)
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 8fa216c

Please sign in to comment.