Closed parsonsmatt closed 1 year ago
Hmm, that's not why #10 can't be implemented like that. I copied the tests into the #21 branch and implemented there, and it works fine.
takeResource
is async exception safe, because
This will send the async exception to takeResource. takeResource will complete
What happens after that is the code you wrote and it's your code that's not async exception safe.
Also, in your example takeResource
will complete only if takeMVar
in waitForResource
doesn't block (or something in createResource
doesn't block).
So timeout $ takeResource pool
is a correct implementation for #10.
Current implementation:
This code does a
mask_
, which means that async exceptions will only be delivered on a blocking call for the duration ofmask_
.So, if I do:
This will send the async exception to
takeResource
.takeResource
will complete, and then the thread blows up with an async exception. This allows for resources to leak, and is why #10 can't simply be implemented astimeout $ takeResource pool
.