* [ruby-core:101938] [Ruby master Feature#14706] Atomic Integer incr/decr
[not found] <redmine.issue-14706.20180423205312.1320@ruby-lang.org>
@ 2021-01-05 20:18 ` dsisnero
2021-01-06 10:34 ` [ruby-core:101951] " nobu
2021-01-06 15:14 ` [ruby-core:101961] " dsisnero
2 siblings, 0 replies; 3+ messages in thread
From: dsisnero @ 2021-01-05 20:18 UTC (permalink / raw)
To: ruby-core
Issue #14706 has been updated by dsisnero (Dominic Sisneros).
should we revisit this now that we have ractor and Feature #17433
----------------------------------------
Feature #14706: Atomic Integer incr/decr
https://bugs.ruby-lang.org/issues/14706#change-89786
* Author: mperham (Mike Perham)
* Status: Open
* Priority: Normal
----------------------------------------
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:101951] [Ruby master Feature#14706] Atomic Integer incr/decr
[not found] <redmine.issue-14706.20180423205312.1320@ruby-lang.org>
2021-01-05 20:18 ` [ruby-core:101938] [Ruby master Feature#14706] Atomic Integer incr/decr dsisnero
@ 2021-01-06 10:34 ` nobu
2021-01-06 15:14 ` [ruby-core:101961] " dsisnero
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2021-01-06 10:34 UTC (permalink / raw)
To: ruby-core
Issue #14706 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Closed
Closed due to duplication.
----------------------------------------
Feature #14706: Atomic Integer incr/decr
https://bugs.ruby-lang.org/issues/14706#change-89804
* Author: mperham (Mike Perham)
* Status: Closed
* Priority: Normal
----------------------------------------
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:101961] [Ruby master Feature#14706] Atomic Integer incr/decr
[not found] <redmine.issue-14706.20180423205312.1320@ruby-lang.org>
2021-01-05 20:18 ` [ruby-core:101938] [Ruby master Feature#14706] Atomic Integer incr/decr dsisnero
2021-01-06 10:34 ` [ruby-core:101951] " nobu
@ 2021-01-06 15:14 ` dsisnero
2 siblings, 0 replies; 3+ messages in thread
From: dsisnero @ 2021-01-06 15:14 UTC (permalink / raw)
To: ruby-core
Issue #14706 has been updated by dsisnero (Dominic Sisneros).
Feature #12607 -
----------------------------------------
Feature #14706: Atomic Integer incr/decr
https://bugs.ruby-lang.org/issues/14706#change-89814
* Author: mperham (Mike Perham)
* Status: Closed
* Priority: Normal
----------------------------------------
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-06 15:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-14706.20180423205312.1320@ruby-lang.org>
2021-01-05 20:18 ` [ruby-core:101938] [Ruby master Feature#14706] Atomic Integer incr/decr dsisnero
2021-01-06 10:34 ` [ruby-core:101951] " nobu
2021-01-06 15:14 ` [ruby-core:101961] " dsisnero
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).