
On 03-09-2014 14:40, Leon Smith wrote:
I think the semantics should probably be for a concurrent close to immediately close the descriptor, with exceptions raised in any threads that are blocked on the descriptor. It seems that any sort of use-case along these lines is going to result in an exception eventually... so you might as well make it prompt. So I still don't see any lock-based solution for my intended semantics.
How far are you willing to go? :) Instead of an Int, you could use [ThreadId] as a set (or any other data structure). The only problem I can see with this approach is: - Thread A adds itself to the [ThreadId] and waits for the Fd. - Thread B starts closing the Fd. - Thread A is awakened from the Fd. - Thread B closes the Fd and sends async exceptions to all [ThreadId], including thread A. - Thread A tries to modify the [ThreadId] again to remove itself, but sees Nothing instead. At this point, thread A has not yet received the async exception, but it *knows* that the exception is coming! Poor thread A :(. Cheers! -- Felipe.