You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using RxJava 3 in combination with the FiberInterop library, there is a challenge in handling cancellations for long-running tasks. Specifically, the current implementation does not provide a mechanism for a long-running function to be notified of a cancellation until emit is invoked. This causes an issue where a function like computeValue cannot be aware of a cancellation event, leading to potential inefficiencies and unnecessary computations.
In the above code, computeValue is a long-running function that takes a cancelled flag to potentially halt its execution if the flow is cancelled. However, the cancelled flag cannot be updated until the emit is called, making it ineffective in stopping the computation early.
To solve this problem, introducing a mechanism like registering onCancel callback or setting an interrupt flag on the virtual thread could effectively signal cancellation to the running task.
Here are some examples of how it might look:
When using RxJava 3 in combination with the FiberInterop library, there is a challenge in handling cancellations for long-running tasks. Specifically, the current implementation does not provide a mechanism for a long-running function to be notified of a cancellation until
emit
is invoked. This causes an issue where a function likecomputeValue
cannot be aware of a cancellation event, leading to potential inefficiencies and unnecessary computations.In the above code,
computeValue
is a long-running function that takes acancelled
flag to potentially halt its execution if the flow is cancelled. However, thecancelled
flag cannot be updated until theemit
is called, making it ineffective in stopping the computation early.To solve this problem, introducing a mechanism like registering
onCancel
callback or setting an interrupt flag on the virtual thread could effectively signal cancellation to the running task.Here are some examples of how it might look:
This approach ensures that the
computeValue
function can be notified of the cancellation event promptly and can stop its execution accordingly.The text was updated successfully, but these errors were encountered: