Skip to content

Conversation

@emyfops
Copy link
Collaborator

@emyfops emyfops commented Jan 12, 2025

This pull request implements a simple yet efficient timer using kotlin's flow
This is the code used for testing:

var time: Long
var time2: Long

timer(1000L) {
    time = System.currentTimeMillis()
    delay(1000L)
    info("Time1: ${System.currentTimeMillis() - time} milliseconds")
}

timer(1000L) {
    time2 = System.currentTimeMillis()
    delay(2000L)
    info("Timer2: ${System.currentTimeMillis() - time2} milliseconds")
}

There was an ever so slightly sleep deviation between 1 to 4 milliseconds, this was most likely caused by the System.currentTimeMillis(), shown as here

@github-actions github-actions bot added triage Requires labelling or review 1.20 feature Suggests or adds a new feature labels Jan 12, 2025
@emyfops emyfops closed this Jan 13, 2025
@emyfops emyfops deleted the feature/buffered-timer branch January 13, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Suggests or adds a new feature triage Requires labelling or review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants