-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Chat.destroy() method, TimerManager class #66
Conversation
6d5a2c2
to
9e5ba02
Compare
69ecd9e
to
1968f04
Compare
pubnub-chat-impl/src/iosMain/kotlin/com/pubnub/chat/internal/timer/PlatformTimer.ios.kt
Outdated
Show resolved
Hide resolved
pubnub-chat-impl/src/iosMain/kotlin/com/pubnub/chat/internal/timer/PlatformTimer.ios.kt
Outdated
Show resolved
Hide resolved
…imer/PlatformTimer.ios.kt Co-authored-by: jguz-pubnub <[email protected]>
…imer/PlatformTimer.ios.kt Co-authored-by: jguz-pubnub <[email protected]>
} | ||
|
||
// this should run 3 times | ||
// let's also try to start it from a background thread to test if cancellation works in that case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you check if cancellation works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's not cancelled by timerManager.destroy() then counter2.value will be > 3
at the end of the test we check if it's exactly 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting cancellation be executed like this:
val runPeriodically1: PlatformTimer
withContext(Dispatchers.Default) {
runPeriodically1 = timerManager.runPeriodically(0.5.seconds) {
counter2.incrementAndGet()
}
}
runPeriodically1.cancel()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add one more test to check cancellation with cancel()
looks like test was flaky, merging |
TimerManager is used to group PlatformTimers and let us cancel them when destroying Chat.