I missed you saying we should nail it first…I already responded on
ruby-core.
But I think I agree with everything except for a couple details:
- I think Thread.stop should release the lock as it does now. That’s a
pretty minor expectation, and since it’s already there (and I know at
least one library depends on it) it should remain. - I’m dubious about the lock being reentrant. In JRuby I’ve implemented
it using a ReentrantLock, which should count up and count down, but it’s
not necessarily a requirement. However I think it would be bad if a
thread could block by setting critical=true when it’s already critical. - I think setting critical=false should only release the lock iff it is
held by the current thread, and do nothing otherwise.
I also agree that a thread terminating while critical is undefined
behavior. But I think most of these questions could be answered by
treating critical= as a globally-shared reentrant mutex.
Thoughts?