From: rr.rosas@... Date: 2016-07-21T12:26:40+00:00 Subject: [ruby-core:76498] [Ruby trunk Bug#12607] Ruby needs an atomic integer Issue #12607 has been updated by Rodrigo Rosenfeld Rosas. I guess the proper way of helping users to write concurrent code in Ruby is to provide concurrent classes in stdlib rather than relying on third-party gems. I don't think it makes sense to write something like 1.+=(value) since 1 is immutable. It makes more sense to provide some Counter class to stdlib which would be thread-safe. And a ConcurrentHash and ConcurrentArray. Those alone would already help a lot. ---------------------------------------- Bug #12607: Ruby needs an atomic integer https://bugs.ruby-lang.org/issues/12607#change-59741 * Author: Shyouhei Urabe * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- (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: