Logo

Programming-Idioms

History of Idiom 33 > diff from v22 to v23

Edit summary for version 23 by 1.7.4:
New JS implementation by user [1.7.4]

Version 22

2017-05-27, 12:03:21

Version 23

2019-01-24, 10:57:30

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.

Code
let x = f(x)
Comments bubble
JavaScript is single threaded, so we can be sure that no other thread will modify x in between :3