aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/control/concurrency/semaphore.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/control/concurrency/semaphore.lux')
-rw-r--r--stdlib/source/library/lux/control/concurrency/semaphore.lux38
1 files changed, 19 insertions, 19 deletions
diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux
index f4e094d3b..f01af9336 100644
--- a/stdlib/source/library/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux
@@ -29,15 +29,15 @@
#open_positions Int
#waiting_list (Queue (Resolver Any))})
-(abstract: #export Semaphore
- (Atom State)
-
+(abstract: .public Semaphore
{#.doc "A tool for controlling access to resources by multiple concurrent processes."}
+ (Atom State)
+
(def: most_positions_possible
(.nat (\ i.interval top)))
- (def: #export (semaphore initial_open_positions)
+ (def: .public (semaphore initial_open_positions)
(-> Nat Semaphore)
(let [max_positions (n.min initial_open_positions
..most_positions_possible)]
@@ -45,7 +45,7 @@
#open_positions (.int max_positions)
#waiting_list queue.empty}))))
- (def: #export (wait semaphore)
+ (def: .public (wait semaphore)
{#.doc (doc "Wait on a semaphore until there are open positions."
"After finishing your work, you must 'signal' to the semaphore that you're done.")}
(Ex [k] (-> Semaphore (Async Any)))
@@ -67,11 +67,11 @@
<get_in_line>)))))
signal)))
- (exception: #export (semaphore_is_maxed_out {max_positions Nat})
+ (exception: .public (semaphore_is_maxed_out {max_positions Nat})
(exception.report
["Max Positions" (%.nat max_positions)]))
- (def: #export (signal semaphore)
+ (def: .public (signal semaphore)
{#.doc (doc "Signal to a semaphore that you're done with your work, and that there is a new open position.")}
(Ex [k] (-> Semaphore (Async (Try Int))))
(let [semaphore (:representation semaphore)]
@@ -97,12 +97,12 @@
(in (#try.Success (get@ #open_positions post)))))))))
)
-(abstract: #export Mutex
- Semaphore
-
+(abstract: .public Mutex
{#.doc "A mutual-exclusion lock that can only be acquired by one process at a time."}
- (def: #export (mutex _)
+ Semaphore
+
+ (def: .public (mutex _)
{#.doc (doc "Creates a brand-new mutex.")}
(-> Any Mutex)
(:abstraction (semaphore 1)))
@@ -115,7 +115,7 @@
(-> Mutex (Async Any))
(|>> :representation ..signal))
- (def: #export (synchronize mutex procedure)
+ (def: .public (synchronize mutex procedure)
{#.doc (doc "Runs the procedure with exclusive control of the mutex.")}
(All [a] (-> Mutex (IO (Async a)) (Async a)))
(do async.monad
@@ -125,23 +125,23 @@
(in output)))
)
-(def: #export limit
+(def: .public limit
{#.doc (doc "Produce a limit for a barrier.")}
(refinement.refinement (n.> 0)))
-(type: #export Limit
+(type: .public Limit
{#.doc (doc "A limit for barriers.")}
(:~ (refinement.type limit)))
-(abstract: #export Barrier
+(abstract: .public Barrier
+ {#.doc "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier."}
+
{#limit Limit
#count (Atom Nat)
#start_turnstile Semaphore
#end_turnstile Semaphore}
- {#.doc "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier."}
-
- (def: #export (barrier limit)
+ (def: .public (barrier limit)
(-> Limit Barrier)
(:abstraction {#limit limit
#count (atom.atom 0)
@@ -173,7 +173,7 @@
[end dec 0 #end_turnstile]
)
- (def: #export (block barrier)
+ (def: .public (block barrier)
{#.doc (doc "Wait on a barrier until all processes have arrived and met the barrier's limit.")}
(-> Barrier (Async Any))
(do async.monad