
On 24 April 2011 18:58, Edward Z. Yang
Well, that will result in a race where, if the foreign call gets interrupted, the asynchronous exception will get queued up and fire immediately once the FFI call completes,
Well the whole block of code is under a mask_ so if FFI calls are not interruptible the queued up exceptions should not be fired. I did a quick test that throwed 1000 exceptions to a thread executing that piece of code but with the uninterruptibleMask_ only around the 'acquire lock'. As expected only the first one got through.
thus enabling libusb_cancel_transfer to be called but not acquire lock to be called. Is that the desired semantics?
No, the desired semantics are that after calling the asynchronous libusb_cancel_transfer, we must wait for the transfer to terminate. Although it's correct to put the uninterruptibleMask_ only around the 'acquire lock' I think I leave it as it is. If for some reason the interruptibility of FFI calls changes in the future I will be safe. Better be safe than sorry. Edward, thanks for your insights. Bas