aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/control/concurrency/actor.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/control/concurrency/actor.lux')
-rw-r--r--stdlib/source/library/lux/control/concurrency/actor.lux36
1 files changed, 17 insertions, 19 deletions
diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux
index 84d41564c..1557a9f89 100644
--- a/stdlib/source/library/lux/control/concurrency/actor.lux
+++ b/stdlib/source/library/lux/control/concurrency/actor.lux
@@ -54,7 +54,7 @@
(Resolver [a Mailbox])])
(IO (List a))))
(do {! io.monad}
- [current (async.poll read)]
+ [current (async.value read)]
(case current
(#.Some [head tail])
(\ ! map (|>> (#.Item head))
@@ -116,7 +116,7 @@
(All [s] (-> (Actor s) (IO Bit)))
(let [[obituary _] (get@ #obituary (:representation actor))]
(|> obituary
- async.poll
+ async.value
(\ io.functor map
(|>> (case> #.None
bit.yes
@@ -127,7 +127,7 @@
(def: .public (obituary' actor)
(All [s] (-> (Actor s) (IO (Maybe (Obituary s)))))
(let [[obituary _] (get@ #obituary (:representation actor))]
- (async.poll obituary)))
+ (async.value obituary)))
(def: .public obituary
{#.doc (example "Await for an actor to stop working.")}
@@ -147,7 +147,7 @@
[|mailbox|&resolve (atom.read! (get@ #mailbox (:representation actor)))]
(loop [[|mailbox| resolve] |mailbox|&resolve]
(do !
- [|mailbox| (async.poll |mailbox|)]
+ [|mailbox| (async.value |mailbox|)]
(case |mailbox|
#.None
(do !
@@ -300,8 +300,7 @@
(message: .public (read! state self)
Nat
(async.resolved (#try.Success [state state])))))]
- (syntax: .public (actor:
- {[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP})
+ (syntax: .public (actor: [[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP])
{#.doc (example "Defines a named actor, with its behavior and internal state."
"Messages for the actor must be defined after the on_mail handler."
<examples>)}
@@ -323,8 +322,8 @@
(~+ messages))))))))
- (syntax: .public (actor {[state_type init] (<code>.record (<>.and <code>.any <code>.any))}
- {[?on_mail messages] behavior^})
+ (syntax: .public (actor [[state_type init] (<code>.record (<>.and <code>.any <code>.any))
+ [?on_mail messages] behavior^])
{#.doc (example "Defines an anonymous actor, with its behavior and internal state."
"Messages for the actor must be defined after the on_mail handler."
(actor {Nat
@@ -371,8 +370,7 @@
(<>.and <code>.any private)
(<>.and (<>\in (` .private)) private))))
- (syntax: .public (message:
- {[export_policy signature annotations output_type body] ..messageP})
+ (syntax: .public (message: [[export_policy signature annotations output_type body] ..messageP])
{#.doc (example "A message can access the actor's state through the state parameter."
"A message can also access the actor itself through the self parameter."
"A message's output must be an async containing a 2-tuple with the updated state and a return value."
@@ -422,12 +420,12 @@
(atom.atom ..continue!))
stop (: Stop
(atom.write! ..stop! signal))]
- (frp.subscribe (function (_ event)
- (do {! io.monad}
- [continue? (atom.read! signal)]
- (if continue?
- (|> actor
- (..mail! (action event stop))
- (\ ! map try.maybe))
- (in #.None))))
- channel)))
+ (frp.subscribe! (function (_ event)
+ (do {! io.monad}
+ [continue? (atom.read! signal)]
+ (if continue?
+ (|> actor
+ (..mail! (action event stop))
+ (\ ! map try.maybe))
+ (in #.None))))
+ channel)))