Less use of callSoon
This commit is contained in:
parent
90247e19ce
commit
0a07bcf66a
|
@ -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`.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20230410"
|
||||
version = "20230502"
|
||||
author = "Emery Hemingway"
|
||||
description = "Syndicated actors for conversational concurrency"
|
||||
license = "Unlicense"
|
||||
|
|
Loading…
Reference in New Issue