basvandijk / regions

Provides the region monad for safely opening and working with scarce resources
Other
30 stars 7 forks source link

But onExit under a mask. #6

Closed qnikst closed 10 years ago

qnikst commented 10 years ago

Previously code had potential race condition, because asynchronous event may arrive when onExit function is in the middle on a register then it will never be called.

This means that it should either be documented (and user will have to provided required protection on his own), or function should be implemented in a safe way. The former approach was choosen.


I'm not sure if this way is the most sane one and maybe we just need to add few more docs.

basvandijk commented 10 years ago

I agree that it should be documented that the opening of the resource and the registration of its finalizer using onExit should be done in a masked state.

Using mask inside onExit doesn't really help since an asynchronous exception can be thrown after the opening of the resource but before the mask in onExit.