From: marcandre-ruby-core@... Date: 2021-01-13T22:40:03+00:00 Subject: [ruby-core:102075] [Ruby master Feature#12607] Ruby needs an atomic integer Issue #12607 has been updated by marcandre (Marc-Andre Lafortune). chrisseaton (Chris Seaton) wrote in #note-28: > > What is the use case for this atomic integer? > > For example for issuing unique IDs across multiple Ractors. You can achieve something similar with `Object.new.object_id` > > or in fact any integer atomic operations other than += 1 > > For example a CAS to update a bank balance is a common requirement. Why atomic though... This can all be achieved with a Ractor. ---------------------------------------- Feature #12607: Ruby needs an atomic integer https://bugs.ruby-lang.org/issues/12607#change-89935 * Author: shyouhei (Shyouhei Urabe) * Status: Feedback * Priority: Normal * Assignee: ko1 (Koichi Sasada) ---------------------------------------- (This one was derived from bug #12463) Although I don't think += would become atomic, at the same time I understand Rodrigo's needs of _easier_ counter variable that resists inter-thread tampering. I don't think ruby's Integer class can be used for that purpose for reasons (mainly because it is not designed with threads in mind). Rather we should introduce a integer class which is carefully designed. Why not import Concurrent::AtomicFixnum into core? -- https://bugs.ruby-lang.org/ Unsubscribe: