From: Robert Feldt Date: 2000-10-27T22:59:34+09:00 Subject: [ruby-talk:5915] Re: [RFC] Towards a new synchronisation primitive On Fri, 27 Oct 2000, hipster wrote: > We need a careful definition of the Ruby scheduler granularity here. > Otherwise even an expression like > > if test_and_set(bar) ... > > can not be guaranteed to be atomic: reschedule between test_and_set > and if-evaluation. (or is this impossible?) > You're right but I was thinking along the lines: def test_and_set(ref_to_bool_var) Thread.critical = true previous_value = ref_to_bool_var ref_to_bool_var = true Thread.critical = false previous_value end only that it is implemented in C and we dont "export" Thread.critical= (I think it's rb_thread_critical_set) to language level (or not even to C level I guess...). Regards, Robert