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

WorkerThread#blockOn implementation note is incorrect #4193

Open
armanbilge opened this issue Dec 6, 2024 · 1 comment
Open

WorkerThread#blockOn implementation note is incorrect #4193

armanbilge opened this issue Dec 6, 2024 · 1 comment

Comments

@armanbilge
Copy link
Member

blockOn may be invoked by directly using the WSTP as an ExecutionContext with scala.concurrent.blocking, no IO involved. So that's not sufficient justification for not using try/catch. Not sure if we can rejustify it, or just have to add it in.

/**
* A mechanism for executing support code before executing a blocking action.
*
* @note
* There is no reason to enclose any code in a `try/catch` block because the only way this
* code path can be exercised is through `IO.delay`, which already handles exceptions.
*/
override def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
prepareForBlocking()
thunk
}

@djspiewak
Copy link
Member

So I think the conclusion of the note is correct even though the reasoning isn't. You can't get into blockOn without being already on the thread pool, which means we're going to be wrapped in a top level try/catch.

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

No branches or pull requests

2 participants