aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/concurrency/atom.lux
blob: a18adabcfc2920c809c1fb364f25c7d962c06edd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(.using
 [library
  [lux (.except if loop)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: (/.Atom it)
  "Atomic references that are safe to mutate concurrently.")

(documentation: /.compare_and_swap!
  (format "Only mutates an atom if you can present its current value."
          \n "That guarantees that atom was not updated since you last read from it."))

(documentation: /.update!
  (format "Updates an atom by applying a function to its current value."
          \n "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds."
          \n "The retries will be done with the new values of the atom, as they show up."))

(documentation: /.write!
  (format "Writes the given value to an atom."
          \n "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds."))

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Atom
             ..compare_and_swap!
             ..update!
             ..write!
             ($.default /.atom)
             ($.default /.read!)]
            []))