Skip to content

Commit b0a92af

Browse files
committed
fixup! fixup! fixup! fixup! src: make BuiltinLoader threadsafe and non-global
1 parent 5f1c364 commit b0a92af

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/node_threadsafe_cow.h

+16-13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ class CopyOnWrite final {
3939
// Write helpers to access the target data structure.
4040
template <typename T>
4141
class ThreadsafeCopyOnWrite final {
42+
private:
43+
// Define this early since some of the public members depend on it
44+
// and some compilers need it to be defined first in that case.
45+
struct Impl {
46+
explicit Impl(const T& data) : data(data) {}
47+
explicit Impl(T&& data) : data(std::move(data)) {}
48+
49+
Impl(const Impl& other);
50+
Impl& operator=(const Impl& other) = delete;
51+
Impl(Impl&& other) = delete;
52+
Impl& operator=(Impl&& other) = delete;
53+
54+
RwLock mutex;
55+
T data;
56+
};
57+
4258
public:
4359
template <typename... Args>
4460
ThreadsafeCopyOnWrite(Args&&... args)
@@ -79,19 +95,6 @@ class ThreadsafeCopyOnWrite final {
7995
Write write() { return Write(this); }
8096

8197
private:
82-
struct Impl {
83-
explicit Impl(const T& data) : data(data) {}
84-
explicit Impl(T&& data) : data(std::move(data)) {}
85-
86-
Impl(const Impl& other);
87-
Impl& operator=(const Impl& other) = delete;
88-
Impl(Impl&& other) = delete;
89-
Impl& operator=(Impl&& other) = delete;
90-
91-
RwLock mutex;
92-
T data;
93-
};
94-
9598
CopyOnWrite<Impl> impl_;
9699
};
97100

0 commit comments

Comments
 (0)