Skip to content

Commit

Permalink
Avoid redundant thread creation by invoking coroutine timeout handlin…
Browse files Browse the repository at this point in the history
…g code on Vert.x threads (#246) (#247)

By the way, it prevents from dispatching the coroutine execution to the context (because it's already executing on the right context).

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
  • Loading branch information
tsegismont committed Oct 13, 2023
1 parent 86ed852 commit b907ff6
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ private class ContextCoroutineDispatcher(val vertxContext: ContextInternal) : Co
override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {
(delegate as Delay).scheduleResumeAfterDelay(timeMillis, continuation)
}

override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle {
return (delegate as Delay).invokeOnTimeout(timeMillis, block, context)
}
}

private class VertxScheduledFuture(
Expand Down

0 comments on commit b907ff6

Please sign in to comment.