diff options
Diffstat (limited to 'stdlib/source/lux/concurrency/actor.lux')
-rw-r--r-- | stdlib/source/lux/concurrency/actor.lux | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index a079d2d28..9f3403aad 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -221,7 +221,7 @@ output (message state self) #let [_ (log! "AFTER")]] (wrap output)))))} - (with-gensyms [g!message g!self g!state g!init g!error g!return g!output] + (with-gensyms [g!init] (do @ [module macro.current-module-name #let [g!type (code.local-symbol (state-name _name)) @@ -229,16 +229,16 @@ g!actor (code.local-symbol _name) g!new (code.local-symbol (new-name _name)) g!vars (list/map code.local-symbol _vars)]] - (wrap (list (` (type: (~@ (csw.export export)) ((~ g!type) (~@ g!vars)) + (wrap (list (` (type: (~+ (csw.export export)) ((~ g!type) (~+ g!vars)) (~ state-type))) - (` (type: (~@ (csw.export export)) ((~ g!actor) (~@ g!vars)) + (` (type: (~+ (csw.export export)) ((~ g!actor) (~+ g!vars)) (~ (|> annotations (with-actor [module _name]) csw.annotations)) - (..Actor ((~ g!type) (~@ g!vars))))) - (` (def: (~@ (csw.export export)) (~ g!behavior) - (All [(~@ g!vars)] - (..Behavior ((~ g!type) (~@ g!vars)))) + (..Actor ((~ g!type) (~+ g!vars))))) + (` (def: (~+ (csw.export export)) (~ g!behavior) + (All [(~+ g!vars)] + (..Behavior ((~ g!type) (~+ g!vars)))) {#..handle (~ (case ?handle #.None (` ..default-handle) @@ -260,10 +260,10 @@ (do P.Monad<Promise> [] (~ bodyC))))))})) - (` (def: (~@ (csw.export export)) ((~ g!new) (~ g!init)) - (All [(~@ g!vars)] - (-> ((~ g!type) (~@ g!vars)) (io.IO ((~ g!actor) (~@ g!vars))))) - (..spawn (~ g!behavior) (~ g!init)))))) + (` (def: (~+ (csw.export export)) ((~ g!new) (~@ g!init)) + (All [(~+ g!vars)] + (-> ((~ g!type) (~+ g!vars)) (io.IO ((~ g!actor) (~+ g!vars))))) + (..spawn (~ g!behavior) (~@ g!init)))))) ))) (type: Signature @@ -313,7 +313,7 @@ #let [g!type (code.symbol (product.both id state-name actor-name)) g!message (code.local-symbol (get@ #name signature)) g!actor-vars (list/map code.local-symbol actor-vars) - g!actor (` ((~ (code.symbol actor-name)) (~@ g!actor-vars))) + actorC (` ((~ (code.symbol actor-name)) (~+ g!actor-vars))) g!all-vars (|> (get@ #vars signature) (list/map code.local-symbol) (list/compose g!actor-vars)) g!inputsC (|> (get@ #inputs signature) (list/map (|>> product.left code.local-symbol))) g!inputsT (|> (get@ #inputs signature) (list/map product.right)) @@ -335,32 +335,32 @@ (code.replace g!var g!ref outputT)) (get@ #output signature) ref-replacements)]] - (wrap (list (` (def: (~@ (csw.export export)) ((~ g!message) (~@ g!inputsC) (~ g!self)) + (wrap (list (` (def: (~+ (csw.export export)) ((~ g!message) (~+ g!inputsC) (~ g!self)) (~ (|> annotations (with-message actor-name) csw.annotations)) - (All [(~@ g!all-vars)] (-> (~@ g!inputsT) (~ g!actor) (T.Task (~ (get@ #output signature))))) - (let [(~ g!task) (T.task (~ g!outputT))] + (All [(~+ g!all-vars)] (-> (~+ g!inputsT) (~ actorC) (T.Task (~ (get@ #output signature))))) + (let [(~@ g!task) (T.task (~ g!outputT))] (io.run (do io.Monad<IO> - [(~ g!sent?) (..send (function [(~ g!state) (~ g!self)] - (do P.Monad<Promise> - [(~ g!return) (: (T.Task [((~ g!type) (~@ g!actor-refs)) - (~ g!outputT)]) - (do T.Monad<Task> - [] - (~ body)))] - (case (~ g!return) - (#.Right [(~ g!state) (~ g!return)]) - (exec (io.run (P.resolve (#.Right (~ g!return)) (~ g!task))) - (T.return (~ g!state))) - - (#.Left (~ g!error)) - (exec (io.run (P.resolve (#.Left (~ g!error)) (~ g!task))) - (T.fail (~ g!error)))) - )) - (~ g!self))] - (if (~ g!sent?) - ((~' wrap) (~ g!task)) + [(~@ g!sent?) (..send (function [(~ g!state) (~ g!self)] + (do P.Monad<Promise> + [(~@ g!return) (: (T.Task [((~ g!type) (~+ g!actor-refs)) + (~ g!outputT)]) + (do T.Monad<Task> + [] + (~ body)))] + (case (~@ g!return) + (#.Right [(~ g!state) (~@ g!return)]) + (exec (io.run (P.resolve (#.Right (~@ g!return)) (~@ g!task))) + (T.return (~ g!state))) + + (#.Left (~@ g!error)) + (exec (io.run (P.resolve (#.Left (~@ g!error)) (~@ g!task))) + (T.fail (~@ g!error)))) + )) + (~ g!self))] + (if (~@ g!sent?) + ((~' wrap) (~@ g!task)) ((~' wrap) (T.throw ..Dead "")))))))) )) ))) |