diff options
Diffstat (limited to 'stdlib/source/test/lux/control/concurrency/semaphore.lux')
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/semaphore.lux | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 38e152456..d1077ae53 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -11,7 +11,7 @@ ["." try] ["." exception (#+ exception:)] [concurrency - ["." promise (#+ Promise)] + ["." async (#+ Async)] ["." atom (#+ Atom)]]] [data ["." maybe] @@ -41,8 +41,8 @@ (do {! random.monad} [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) #let [semaphore (/.semaphore initial_open_positions)]] - (wrap (do promise.monad - [result (promise.time_out ..delay (/.wait semaphore))] + (wrap (do async.monad + [result (async.time_out ..delay (/.wait semaphore))] (_.cover' [/.semaphore] (case result (#.Some _) @@ -53,9 +53,9 @@ (do {! random.monad} [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) #let [semaphore (/.semaphore initial_open_positions)]] - (wrap (do {! promise.monad} + (wrap (do {! async.monad} [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) - result (promise.time_out ..delay (/.wait semaphore))] + result (async.time_out ..delay (/.wait semaphore))] (_.cover' [/.wait] (case result (#.Some _) @@ -66,12 +66,12 @@ (do {! random.monad} [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) #let [semaphore (/.semaphore initial_open_positions)]] - (wrap (do {! promise.monad} + (wrap (do {! async.monad} [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) #let [block (/.wait semaphore)] - result/0 (promise.time_out ..delay block) + result/0 (async.time_out ..delay block) open_positions (/.signal semaphore) - result/1 (promise.time_out ..delay block)] + result/1 (async.time_out ..delay block)] (_.cover' [/.signal] (case [result/0 result/1 open_positions] [#.None (#.Some _) (#try.Success +0)] @@ -82,7 +82,7 @@ (do {! random.monad} [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) #let [semaphore (/.semaphore initial_open_positions)]] - (wrap (do promise.monad + (wrap (do async.monad [outcome (/.signal semaphore)] (_.cover' [/.semaphore_is_maxed_out] (case outcome @@ -105,7 +105,7 @@ mutex (/.mutex []) processA (<| (/.synchronize mutex) io.io - promise.future + async.future (do {! io.monad} [_ (<| (monad.seq !) (list.repeat repetitions) @@ -113,13 +113,13 @@ (wrap []))) processB (<| (/.synchronize mutex) io.io - promise.future + async.future (do {! io.monad} [_ (<| (monad.seq !) (list.repeat repetitions) (atom.update (|>> (format "B")) resource))] (wrap [])))]] - (wrap (do promise.monad + (wrap (do async.monad [_ processA _ processB #let [outcome (io.run (atom.read resource))]] @@ -131,10 +131,10 @@ ))) (def: (waiter resource barrier id) - (-> (Atom Text) /.Barrier Nat (Promise Any)) - (do promise.monad + (-> (Atom Text) /.Barrier Nat (Async Any)) + (do async.monad [_ (/.block barrier) - _ (promise.future (atom.update (|>> (format (%.nat id))) resource))] + _ (async.future (atom.update (|>> (format (%.nat id))) resource))] (wrap []))) (def: barrier @@ -158,7 +158,7 @@ [limit (\ ! map (|>> (n.% 9) inc) random.nat) #let [barrier (/.barrier (maybe.assume (/.limit limit))) resource (atom.atom "")]] - (wrap (do {! promise.monad} + (wrap (do {! async.monad} [#let [suffix "_" expected_ending (|> suffix (list.repeat limit) |