Skip to content

Commit

Permalink
We really need to do the load_state again after a failed casWeak
Browse files Browse the repository at this point in the history
The original c++ source uses compare_exchange_weak which loads the value
if the compare failes. casWeak doesn't load it on failure.
  • Loading branch information
skoppe committed Jan 18, 2021
1 parent fd05f06 commit f5e280f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions source/concurrency/stoptoken.d
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,12 @@ public:

bool try_add_callback(StopCallback cb, bool incrementRefCountIfSuccessful) nothrow @safe {
ulong oldState;
goto load_state;
do {
goto check_state;
goto load_state;
do {
spin_yield();
load_state:
oldState = state_.atomicLoad!(MemoryOrder.acq);
check_state:
if (is_stop_requested(oldState)) {
cb.execute();
return false;
Expand Down

0 comments on commit f5e280f

Please sign in to comment.