aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/concurrency/semaphore.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/control/concurrency/semaphore.lux')
-rw-r--r--stdlib/source/test/lux/control/concurrency/semaphore.lux24
1 files changed, 12 insertions, 12 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux
index a57e3bcd6..b4b07bbb0 100644
--- a/stdlib/source/test/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux
@@ -42,7 +42,7 @@
[initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1))))
.let [semaphore (/.semaphore initial_open_positions)]]
(in (do async.monad
- [result (async.time_out ..delay (/.wait! semaphore))]
+ [result (async.within ..delay (/.wait! semaphore))]
(_.cover' [/.semaphore]
(case result
(#.Some _)
@@ -55,7 +55,7 @@
.let [semaphore (/.semaphore initial_open_positions)]]
(in (do {! async.monad}
[_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore))
- result (async.time_out ..delay (/.wait! semaphore))]
+ result (async.within ..delay (/.wait! semaphore))]
(_.cover' [/.wait!]
(case result
(#.Some _)
@@ -69,9 +69,9 @@
(in (do {! async.monad}
[_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore))
.let [block (/.wait! semaphore)]
- result/0 (async.time_out ..delay block)
+ result/0 (async.within ..delay block)
open_positions (/.signal! semaphore)
- result/1 (async.time_out ..delay block)]
+ result/1 (async.within ..delay block)]
(_.cover' [/.signal!]
(case [result/0 result/1 open_positions]
[#.None (#.Some _) (#try.Success +0)]
@@ -100,14 +100,14 @@
(do {! random.monad}
[repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10))))
.let [resource (atom.atom "")
- expected_As (text.joined (list.repeated repetitions "A"))
- expected_Bs (text.joined (list.repeated repetitions "B"))
+ expected_As (text.together (list.repeated repetitions "A"))
+ expected_Bs (text.together (list.repeated repetitions "B"))
mutex (/.mutex [])
processA (<| (/.synchronize! mutex)
io.io
async.future
(do {! io.monad}
- [_ (<| (monad.seq !)
+ [_ (<| (monad.all !)
(list.repeated repetitions)
(atom.update! (|>> (format "A")) resource))]
(in [])))
@@ -115,7 +115,7 @@
io.io
async.future
(do {! io.monad}
- [_ (<| (monad.seq !)
+ [_ (<| (monad.all !)
(list.repeated repetitions)
(atom.update! (|>> (format "B")) resource))]
(in [])))]]
@@ -155,21 +155,21 @@
_
false)))
(do {! random.monad}
- [limit (\ ! map (|>> (n.% 9) inc) random.nat)
+ [limit (\ ! map (|>> (n.% 9) ++) random.nat)
.let [barrier (/.barrier (maybe.trusted (/.limit limit)))
resource (atom.atom "")]]
(in (do {! async.monad}
[.let [suffix "_"
expected_ending (|> suffix
(list.repeated limit)
- text.joined)
- expected_ids (enum.range n.enum 0 (dec limit))]
+ text.together)
+ expected_ids (enum.range n.enum 0 (-- limit))]
_ (|> expected_ids
(list\map (function (_ id)
(exec
(io.run! (atom.update! (|>> (format suffix)) resource))
(waiter resource barrier id))))
- (monad.seq !))
+ (monad.all !))
.let [outcome (io.run! (atom.read! resource))]]
(_.cover' [/.barrier /.block!]
(and (text.ends_with? expected_ending outcome)