Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support noncopyable sync objects #2766

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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: 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
Loading