Less use of callSoon

This commit is contained in:
Emery Hemingway 2023-05-02 22:24:19 +01:00
parent 90247e19ce
commit 0a07bcf66a
2 changed files with 8 additions and 13 deletions

View File

@ -395,8 +395,7 @@ proc spawn*(name: string; turn: var Turn; bootProc: TurnAction; initialAssertion
var newOutBound: Table[Handle, OutboundAssertion]
for key in initialAssertions:
discard turn.facet.outbound.pop(key, newOutbound[key])
callSoon do ():
discard newActor(name, bootProc, newOutBound)
discard newActor(name, bootProc, newOutBound)
proc newInertRef*(): Ref =
let a = bootActor("inert") do (turn: var Turn): turn.stop()
@ -434,22 +433,18 @@ template tryFacet(facet; body: untyped) =
#try: body
#except: terminate(facet, getCurrentException())
proc run(queues: Queues) =
callSoon do ():
for facet, queue in queues:
for action in queue: run(facet, action)
proc run*(facet; action: TurnAction; zombieTurn = false) =
if not zombieTurn:
if not facet.actor.exitReason.isNil: return
if not facet.isAlive: return
# TODO: not Nim idiom
tryFacet(facet):
var turn = Turn(
facet: facet,
queues: newTable[Facet, seq[TurnAction]]())
action(turn)
run(turn.queues)
var queues = newTable[Facet, seq[TurnAction]]()
block:
var turn = Turn(facet: facet, queues: queues)
action(turn)
for facet, queue in queues:
for action in queue: run(facet, action)
proc run*(`ref`: Ref; action: TurnAction) =
## Convenience proc to run a `TurnAction` in the scope of a `Ref`.

View File

@ -1,6 +1,6 @@
# Package
version = "20230410"
version = "20230502"
author = "Emery Hemingway"
description = "Syndicated actors for conversational concurrency"
license = "Unlicense"