Skip to content
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

Thread parking for Kotlin/Common #498

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bbrockbernd
Copy link
Collaborator

Allows to pause and resume thread execution. On native platforms it is based on pthread_cond_wait, on JVM it uses LockSupport.

Threads can be pre unparked (calling unpark before park cancels the parking operation). And thread can be parker with a timeout.

Suspend the current thread by calling:

Parker.park()

Resume a thread by calling:

Parker.unpark(thread)

Get current thread reference by calling:

val thread = KThread.currentThread()

Parking with timout of 500 nano seconds:

Parker.parkNanos(500)

@bbrockbernd bbrockbernd marked this pull request as ready for review December 19, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant