Skip to content

ActorSystem should continue use std atomic #643

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

Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions ydb/library/actors/util/should_continue.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#include "should_continue.h"

void TProgramShouldContinue::ShouldRestart() {
AtomicSet(State, Restart);
State.store(Restart, std::memory_order_release);
}

void TProgramShouldContinue::ShouldStop(int returnCode) {
AtomicSet(ReturnCode, returnCode);
AtomicSet(State, Stop);
ReturnCode.store(returnCode, std::memory_order_release);
State.store(Stop, std::memory_order_release);
}

TProgramShouldContinue::EState TProgramShouldContinue::PollState() {
return static_cast<EState>(AtomicGet(State));
return State.load(std::memory_order_acquire);
}

int TProgramShouldContinue::GetReturnCode() {
return static_cast<int>(AtomicGet(ReturnCode));
return ReturnCode.load(std::memory_order_acquire);
}

void TProgramShouldContinue::Reset() {
AtomicSet(ReturnCode, 0);
AtomicSet(State, Continue);
ReturnCode.store(0, std::memory_order_release);
State.store(Continue, std::memory_order_release);
}
4 changes: 2 additions & 2 deletions ydb/library/actors/util/should_continue.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class TProgramShouldContinue {

void Reset();
private:
TAtomic ReturnCode = 0;
TAtomic State = Continue;
std::atomic<int> ReturnCode = 0;
std::atomic<EState> State = Continue;
};