@TomasStanek
@alexandru It's not about being GC heavy, it's about that the loop brings jvm gradually to halt. (I'm observing that with 1.0.0-RC2, and I'll try that with 1.0.0-RC3 when it's out). What you say is therefore that the cancelation is not synchronized (and will never be - it is by design) and the user must therefore employ other means of synchronization, if there are some resources to be freed to continue safely, right?
What do you mean by cancelation not being synchronized?
I will test, but no, race
shouldn't leak if the underlying scheduler doesn't and if the underlying scheduler leaks, then there's nothing we can do.
I'm not discounting the possibility of a bug, but if you're having problems, it has nothing to do with #305
So if you get more hints, open an issue.
@TomasStanek the current code is like this:
if (isActive.getAndSet(false)) {
// First interrupts the other task
try other.cancel() finally {
main.pop()
cb(Right(r))
}
What happens is that the loser gets cancelled before the winner's result is signaled. Now if that cancellation logic is synchronous, there shouln't be any issues. But if that cancellation logic happens asynchronously, then indeed you might have issues, however cancelling a timeout
shouldn't be async obviously.
In the new code in that PR, it is now changed to this:
if (isActive.getAndSet(false)) {
// First interrupts the other task
other.cancel.unsafeRunAsync { r2 =>
main.pop()
cb(Right(r))
maybeReport(r2)
}
So now the cancellation can happen asynchronously, although there are some caveats here as well, because due to multi-threading, there's always the possibility that the finalizer you want might not be registered yet, but that's another discussion.
Resource
and struggling to understand why it's there; it appears superfluous to Bracket
, as Resource.use
requires an implicit Bracket
. Is this just so that if your clean-up code is unwieldy, you can avoid writing F.bracket(<my huge initialization/finalization code>)
?
io.Socket
into a Resource
. I guess that' swhere this is going ... but go on.
pure
.
pure
)
readFromFile
fails
bracket
closes a resource as soon as the F finishes emitting elements
pure
, you emit, so you have finished emitting, so the resource gets closed
emit
on Stream, the stream has not finished emitting, because a Stream, unlike IO, can emit multiple elements, and therefore the thing is still fine