Skip to content

Commit

Permalink
feat(session) Make isPaused private
Browse files Browse the repository at this point in the history
  • Loading branch information
YYChen01988 committed Apr 16, 2024
1 parent a96b03a commit ffb7446
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class Session implements JsonStream.Streamable, UserAware {
private final AtomicInteger unhandledCount = new AtomicInteger();
private final AtomicInteger handledCount = new AtomicInteger();
private final AtomicBoolean tracked = new AtomicBoolean(false);
final AtomicBoolean isPaused = new AtomicBoolean(false);
private final AtomicBoolean isPaused = new AtomicBoolean(false);

private String apiKey;

Expand Down Expand Up @@ -202,10 +202,18 @@ boolean markTracked() {
return tracked.compareAndSet(false, true);
}

boolean markPaused() {
boolean markResumed() {
return isPaused.compareAndSet(true, false);
}

void markPaused() {
isPaused.set(true);
}

boolean isPaused() {
return isPaused.get();
}

boolean isAutoCaptured() {
return autoCaptured;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void pauseSession() {
Session session = currentSession;

if (session != null) {
session.isPaused.set(true);
session.markPaused();
updateState(StateEvent.PauseSession.INSTANCE);
}
}
Expand All @@ -133,7 +133,7 @@ boolean resumeSession() {
session = startSession(false);
resumed = false;
} else {
resumed = session.markPaused();
resumed = session.markResumed();
}

if (session != null) {
Expand Down Expand Up @@ -205,7 +205,7 @@ private boolean trackSessionIfNeeded(final Session session) {
Session getCurrentSession() {
Session session = currentSession;

if (session != null && !session.isPaused.get()) {
if (session != null && !session.isPaused()) {
return session;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class SessionTest {
assertEquals(getUser(), copy.getUser()) // make a shallow copy
assertEquals(isAutoCaptured, copy.isAutoCaptured)
assertEquals(markTracked(), copy.markTracked())
assertEquals(markResumed(), copy.markResumed())
assertEquals(isPaused, copy.isPaused)
assertEquals(markPaused(), copy.markPaused())
assertEquals(session.unhandledCount, copy.unhandledCount)
assertEquals(session.handledCount, copy.handledCount)
Expand Down

0 comments on commit ffb7446

Please sign in to comment.