-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
repo-panama
The current implementation for shared segment is based on the idea that, if a thread is closing a segment while the segment is being accessed by other threads, the closing thread should terminate all other threads using an asynchronous exception.
While this approach is elegant (the close operation always succeeds) there are some low level implementation issues associated with the fact that async exceptions are not dealt with uniformly across the VM (and compilers); so there is a non trivial chance that a code path which does not check for async exception might create problems down the road.
A workaround would be not to rely on async exceptions; instead, we could have close() fail - while this seems mildly unpleasant, in reality this still achieves the API safety goal, and it is a clear sign that user requires more synchronization.
While this approach is elegant (the close operation always succeeds) there are some low level implementation issues associated with the fact that async exceptions are not dealt with uniformly across the VM (and compilers); so there is a non trivial chance that a code path which does not check for async exception might create problems down the road.
A workaround would be not to rely on async exceptions; instead, we could have close() fail - while this seems mildly unpleasant, in reality this still achieves the API safety goal, and it is a clear sign that user requires more synchronization.