The implementation has been garbled. So here it is again:
class Thread
def self.atomic
old = self.critical
self.critical = true
begin
yield
ensure
self.critical = old
end
end
end
Guy, thanks for that hint!
-- Robert
I recommend to use Mutex (or Monitor) instead of Thread#critical, which is designed to be an internal kludge to implement mutex etc.
-- matz.
Matz, I couldn't agree more. But apparently there are people who want to use Thread.critical - Thread.atomic could help them to make less errors.
-- Robert
What's wrong with Thread.exclusive { ... } (from thread.rb)?
-- Paul Brannan
Probably that I didn't find it. Documentation seems to be missing:
Thanks for that hint, Paul!
Withdrawing RCR...
-- Robert
The implementation has been garbled. So here it is again:
Guy, thanks for that hint!
-- Robert
I recommend to use Mutex (or Monitor) instead of Thread#critical, which is designed to be an internal kludge to implement mutex etc.
-- matz.
Matz, I couldn't agree more. But apparently there are people who want to use Thread.critical - Thread.atomic could help them to make less errors.
-- Robert
What's wrong with Thread.exclusive { ... } (from thread.rb)?
-- Paul Brannan
Probably that I didn't find it. Documentation seems to be missing:
Thanks for that hint, Paul!
Withdrawing RCR...
-- Robert