From: shevegen@... Date: 2018-04-24T09:53:34+00:00 Subject: [ruby-core:86662] [Ruby trunk Feature#14706] Atomic Integer incr/decr Issue #14706 has been updated by shevegen (Robert A. Heiler). I guess this may come up several times in the future. Would this be a good candidate for discussion in the upcoming ruby developer meeting? I don't want to suggest it myself since I was not the one who started the thread (that was Mike), but it seems to come up every now and then by different people, so it may be of some relevance. Rafael Fran��a pointed out that it was parially rejected/closed but I think that did not come via matz primarily since he did not comment on it; it may be that other ruby developers pointed out some problems with it before, like Koichi; but it may still be good to have matz comment on it so that people can understand what the remaining problems may be, if there are some. ---------------------------------------- Feature #14706: Atomic Integer incr/decr https://bugs.ruby-lang.org/issues/14706#change-71621 * Author: mperham (Mike Perham) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Ruby does not any thread-safe way to implement simple counters without a Mutex. Today Ruby provides Integer#succ but this funcalls "+", making it thread-unsafe as far as I know. I'd propose adding Integer#incr(amount=1) and Integer#reset which would use atomic operations, giving us thread-safe, high-performance counters. ~~~ ruby counter = 0 counter.incr # => 1 counter.incr(10) # => 11 counter.incr(-1) # => 10 counter.reset # => 10 counter # => 0 ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: