2014-01-26 00:04:22 +00:00
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Atoms are like refs"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= __ @atomic-clock)
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "You can change at the swap meet"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= __ (do
|
|
|
|
|
(swap! atomic-clock inc)
|
|
|
|
|
@atomic-clock))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Keep taxes out of this: swapping requires no transaction"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= 5 (do
|
|
|
|
|
__
|
|
|
|
|
@atomic-clock))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Any number of arguments might happen during a swap"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= __ (do
|
|
|
|
|
(swap! atomic-clock + 1 2 3 4 5)
|
|
|
|
|
@atomic-clock))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Atomic atoms are atomic"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= __ (do
|
|
|
|
|
(compare-and-set! atomic-clock 100 :fin)
|
|
|
|
|
@atomic-clock))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "When your expectations are aligned with reality, things proceed that way"
|
2011-03-31 12:44:54 +00:00
|
|
|
(= :fin (do
|
|
|
|
|
(compare-and-set! __ __ __)
|
2016-02-27 02:33:05 +00:00
|
|
|
@atomic-clock))
|