Skip to content

Commit 53ed566

Browse files
author
Matveev Sergei
committed
fixed notes
1 parent 01ae8f7 commit 53ed566

File tree

1 file changed

+5
-39
lines changed

1 file changed

+5
-39
lines changed

ydb/core/tx/columnshard/common/thread_safe_optional.h

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,7 @@ class TThreadSafeOptional {
3737
}
3838
}
3939

40-
TThreadSafeOptional& operator=(const TThreadSafeOptional& other) {
41-
if (this == &other) {
42-
return *this;
43-
}
44-
45-
const bool has = other.Defined.load(std::memory_order_acquire);
46-
if (Has()) {
47-
Ptr()->~T();
48-
Defined.store(false, std::memory_order_release);
49-
}
50-
51-
if (has) {
52-
::new (Ptr()) T(*other.Ptr());
53-
Defined.store(true, std::memory_order_release);
54-
}
55-
56-
return *this;
57-
}
40+
TThreadSafeOptional& operator=(const TThreadSafeOptional& other) = delete;
5841

5942
TThreadSafeOptional(TThreadSafeOptional&& other) noexcept {
6043
const bool has = other.Defined.load(std::memory_order_acquire);
@@ -69,12 +52,8 @@ class TThreadSafeOptional {
6952
return *this;
7053
}
7154

55+
AFL_VERIFY(!Has());
7256
const bool has = other.Defined.load(std::memory_order_acquire);
73-
if (Has()) {
74-
Ptr()->~T();
75-
Defined.store(false, std::memory_order_release);
76-
}
77-
7857
if (has) {
7958
::new (Ptr()) T(std::move(*other.Ptr()));
8059
Defined.store(true, std::memory_order_release);
@@ -83,29 +62,16 @@ class TThreadSafeOptional {
8362
return *this;
8463
}
8564

86-
void Reset() {
87-
if (Has()) {
88-
Ptr()->~T();
89-
Defined.store(false, std::memory_order_release);
90-
}
91-
}
65+
void Reset() = delete;
9266

9367
void Set(const T& value) {
94-
if (Has()) {
95-
Ptr()->~T();
96-
Defined.store(false, std::memory_order_release);
97-
}
98-
68+
AFL_VERIFY(!Has());
9969
::new (Ptr()) T(value);
10070
Defined.store(true, std::memory_order_release);
10171
}
10272

10373
void Set(T&& value) {
104-
if (Has()) {
105-
Ptr()->~T();
106-
Defined.store(false, std::memory_order_release);
107-
}
108-
74+
AFL_VERIFY(!Has());
10975
::new (Ptr()) T(std::move(value));
11076
Defined.store(true, std::memory_order_release);
11177
}

0 commit comments

Comments
 (0)