Skip to content

Commit

Permalink
Read the Atomic reference variable in the loop to avoid cpu run off. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shailesh33 authored and ipapapa committed Feb 1, 2018
1 parent 7ada67c commit 21fe6ed
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ public void begin() {
@Override
public void success() {
boolean success = false;
RetryState rs = state.get();
RetryState rs;
while (!success) {
rs = state.get();
success = state.compareAndSet(rs, new RetryState(rs.count + 1, true));
}
}

@Override
public void failure(Exception e) {
boolean success = false;
RetryState rs = state.get();
RetryState rs;
while (!success) {
rs = state.get();
success = state.compareAndSet(rs, new RetryState(rs.count + 1, false));
}
}
Expand Down

0 comments on commit 21fe6ed

Please sign in to comment.