aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/concurrency/semaphore.lux
blob: 74b441df04fb9491d4605ad592d163bb6c2c7f51 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(.using
 [library
  [lux (.except if loop)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: /.Semaphore
  "A tool for controlling access to resources by multiple concurrent processes.")

(documentation: /.semaphore
  ""
  [(semaphore initial_open_positions)])

(documentation: /.wait!
  (format "Wait on a semaphore until there are open positions."
          \n "After finishing your work, you must 'signal' to the semaphore that you're done.")
  [(wait! semaphore)])

(documentation: /.signal!
  "Signal to a semaphore that you're done with your work, and that there is a new open position."
  [(signal! semaphore)])

(documentation: /.Mutex
  "A mutual-exclusion lock that can only be acquired by one process at a time.")

(documentation: /.mutex
  "Creates a brand-new mutex."
  [(mutex _)])

(documentation: /.synchronize!
  "Runs the procedure with exclusive control of the mutex."
  [(synchronize! mutex procedure)])

(documentation: /.limit
  "Produce a limit for a barrier.")

(documentation: /.Limit
  "A limit for barriers.")

(documentation: /.Barrier
  "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier.")

(documentation: /.block!
  "Wait on a barrier until all processes have arrived and met the barrier's limit.")

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Semaphore
             ..semaphore
             ..wait!
             ..signal!
             ..Mutex
             ..mutex
             ..synchronize!
             ..limit
             ..Limit
             ..Barrier
             ..block!
             ($.default /.semaphore_is_maxed_out)
             ($.default /.barrier)]
            []))