aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/control/concurrency/semaphore.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/control/concurrency/semaphore.lux76
1 files changed, 38 insertions, 38 deletions
diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux
index 56ab29a03..58e664966 100644
--- a/stdlib/source/library/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux
@@ -1,28 +1,28 @@
(.using
- [library
- [lux "*"
- [abstract
- [monad {"+" do}]]
- [control
- [pipe {"+" if>}]
- ["[0]" io {"+" IO}]
- ["[0]" try {"+" Try}]
- ["[0]" exception {"+" exception:}]]
- [data
- [text
- ["%" format {"+" format}]]
- [collection
- ["[0]" queue {"+" Queue}]]]
- [math
- [number
- ["n" nat]
- ["i" int]]]
- [type
- abstract
- ["[0]" refinement]]]]
- [//
- ["[0]" atom {"+" Atom}]
- ["[0]" async {"+" Async Resolver}]])
+ [library
+ [lux "*"
+ [abstract
+ [monad {"+" do}]]
+ [control
+ [pipe {"+" if>}]
+ ["[0]" io {"+" IO}]
+ ["[0]" try {"+" Try}]
+ ["[0]" exception {"+" exception:}]]
+ [data
+ [text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" queue {"+" Queue}]]]
+ [math
+ [number
+ ["n" nat]
+ ["i" int]]]
+ [type
+ abstract
+ ["[0]" refinement]]]]
+ [//
+ ["[0]" atom {"+" Atom}]
+ ["[0]" async {"+" Async Resolver}]])
(type: State
(Record
@@ -51,12 +51,12 @@
(async.async []))]
(exec
(io.run!
- (with_expansions [<had_open_position?> (as_is (value@ #open_positions) (i.> -1))]
+ (with_expansions [<had_open_position?> (as_is (the #open_positions) (i.> -1))]
(do io.monad
- [[_ state'] (atom.update! (|>> (revised@ #open_positions --)
+ [[_ state'] (atom.update! (|>> (revised #open_positions --)
(if> [<had_open_position?>]
[]
- [(revised@ #waiting_list (queue.end sink))]))
+ [(revised #waiting_list (queue.end sink))]))
semaphore)]
(with_expansions [<go_ahead> (sink [])
<get_in_line> (in false)]
@@ -75,23 +75,23 @@
(async.future
(do [! io.monad]
[[pre post] (atom.update! (function (_ state)
- (if (i.= (.int (value@ #max_positions state))
- (value@ #open_positions state))
+ (if (i.= (.int (the #max_positions state))
+ (the #open_positions state))
state
(|> state
- (revised@ #open_positions ++)
- (revised@ #waiting_list queue.next))))
+ (revised #open_positions ++)
+ (revised #waiting_list queue.next))))
semaphore)]
(if (same? pre post)
- (in (exception.except ..semaphore_is_maxed_out [(value@ #max_positions pre)]))
+ (in (exception.except ..semaphore_is_maxed_out [(the #max_positions pre)]))
(do !
- [_ (case (queue.front (value@ #waiting_list pre))
+ [_ (case (queue.front (the #waiting_list pre))
{.#None}
(in true)
{.#Some sink}
(sink []))]
- (in {try.#Success (value@ #open_positions post)})))))))
+ (in {try.#Success (the #open_positions post)})))))))
)
(abstract: .public Mutex
@@ -151,13 +151,13 @@
[(def: (<phase> (^:representation barrier))
(-> Barrier (Async Any))
(do async.monad
- [.let [limit (refinement.value (value@ #limit barrier))
+ [.let [limit (refinement.value (the #limit barrier))
goal <goal>
- [_ count] (io.run! (atom.update! <update> (value@ #count barrier)))
+ [_ count] (io.run! (atom.update! <update> (the #count barrier)))
reached? (n.= goal count)]]
(if reached?
- (..un_block! (-- limit) (value@ <turnstile> barrier))
- (..wait! (value@ <turnstile> barrier)))))]
+ (..un_block! (-- limit) (the <turnstile> barrier))
+ (..wait! (the <turnstile> barrier)))))]
[start! ++ limit #start_turnstile]
[end! -- 0 #end_turnstile]