Logo

Programming-Idioms

History of Idiom 33 > diff from v7 to v8

Edit summary for version 8 by :

Version 7

2015-09-03, 17:05:00

Version 8

2015-09-03, 17:05:16

Idiom #33 Atomically read and update variable

Assign variable x the new value f(x), making sure that no other thread may modify x between the read and the write.

Idiom #33 Atomically read and update variable

Assign variable x the new value f(x), making sure that no other thread may modify x between the read and the write.

Imports
require 'atomic'https://github.com/ruby-concurrency/atomic
Imports
require 'atomic'
Code
x = Atomic.new(0)
x.update { |x| f(x) }
Code
x = Atomic.new(0)
x.update { |x| f(x) }
Doc URL
https://github.com/ruby-concurrency/atomic
Doc URL
https://github.com/ruby-concurrency/atomic
Origin
https://github.com/ruby-concurrency/atomic
Origin
https://github.com/ruby-concurrency/atomic