diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/control/concurrency/semaphore.lux | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index c266617a5..e2cdb2aca 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -52,12 +52,12 @@ (async.async []))] (exec (io.run! - (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] + (with_expansions [<had_open_position?> (as_is (value@ #open_positions) (i.> -1))] (do io.monad - [[_ state'] (atom.update! (|>> (update@ #open_positions dec) + [[_ state'] (atom.update! (|>> (revised@ #open_positions --) (if> [<had_open_position?>] [] - [(update@ #waiting_list (queue.end sink))])) + [(revised@ #waiting_list (queue.end sink))])) semaphore)] (with_expansions [<go_ahead> (sink []) <get_in_line> (in false)] @@ -76,23 +76,23 @@ (async.future (do {! io.monad} [[pre post] (atom.update! (function (_ state) - (if (i.= (.int (get@ #max_positions state)) - (get@ #open_positions state)) + (if (i.= (.int (value@ #max_positions state)) + (value@ #open_positions state)) state (|> state - (update@ #open_positions inc) - (update@ #waiting_list queue.next)))) + (revised@ #open_positions ++) + (revised@ #waiting_list queue.next)))) semaphore)] (if (same? pre post) - (in (exception.except ..semaphore_is_maxed_out [(get@ #max_positions pre)])) + (in (exception.except ..semaphore_is_maxed_out [(value@ #max_positions pre)])) (do ! - [_ (case (queue.front (get@ #waiting_list pre)) + [_ (case (queue.front (value@ #waiting_list pre)) #.None (in true) (#.Some sink) (sink []))] - (in (#try.Success (get@ #open_positions post))))))))) + (in (#try.Success (value@ #open_positions post))))))))) ) (abstract: .public Mutex @@ -148,23 +148,23 @@ (if (n.< times step) (do async.monad [outcome (..signal! turnstile)] - (recur (inc step))) + (recur (++ step))) (\ async.monad in [])))) (template [<phase> <update> <goal> <turnstile>] [(def: (<phase> (^:representation barrier)) (-> Barrier (Async Any)) (do async.monad - [.let [limit (refinement.value (get@ #limit barrier)) + [.let [limit (refinement.value (value@ #limit barrier)) goal <goal> - [_ count] (io.run! (atom.update! <update> (get@ #count barrier))) + [_ count] (io.run! (atom.update! <update> (value@ #count barrier))) reached? (n.= goal count)]] (if reached? - (..un_block! (dec limit) (get@ <turnstile> barrier)) - (..wait! (get@ <turnstile> barrier)))))] + (..un_block! (-- limit) (value@ <turnstile> barrier)) + (..wait! (value@ <turnstile> barrier)))))] - [start! inc limit #start_turnstile] - [end! dec 0 #end_turnstile] + [start! ++ limit #start_turnstile] + [end! -- 0 #end_turnstile] ) (def: .public (block! barrier) |