Skip to content

Commit 484732a

Browse files
kitaisrealadameat
authored andcommitted
ActorSystem should continue use std atomic (ydb-platform#643)
1 parent d931fd8 commit 484732a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#include "should_continue.h"
22

33
void TProgramShouldContinue::ShouldRestart() {
4-
AtomicSet(State, Restart);
4+
State.store(Restart, std::memory_order_release);
55
}
66

77
void TProgramShouldContinue::ShouldStop(int returnCode) {
8-
AtomicSet(ReturnCode, returnCode);
9-
AtomicSet(State, Stop);
8+
ReturnCode.store(returnCode, std::memory_order_release);
9+
State.store(Stop, std::memory_order_release);
1010
}
1111

1212
TProgramShouldContinue::EState TProgramShouldContinue::PollState() {
13-
return static_cast<EState>(AtomicGet(State));
13+
return State.load(std::memory_order_acquire);
1414
}
1515

1616
int TProgramShouldContinue::GetReturnCode() {
17-
return static_cast<int>(AtomicGet(ReturnCode));
17+
return ReturnCode.load(std::memory_order_acquire);
1818
}
1919

2020
void TProgramShouldContinue::Reset() {
21-
AtomicSet(ReturnCode, 0);
22-
AtomicSet(State, Continue);
21+
ReturnCode.store(0, std::memory_order_release);
22+
State.store(Continue, std::memory_order_release);
2323
}

ydb/library/actors/util/should_continue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class TProgramShouldContinue {
1717

1818
void Reset();
1919
private:
20-
TAtomic ReturnCode = 0;
21-
TAtomic State = Continue;
20+
std::atomic<int> ReturnCode = 0;
21+
std::atomic<EState> State = Continue;
2222
};

0 commit comments

Comments
 (0)