Compare commits

...

3 Commits

Author SHA1 Message Date
Emery Hemingway 4bdf220377 Implement base method of sync 2024-04-24 16:12:49 +02:00
Emery Hemingway c99f0a60ab Add runOnce proc
This is useful for forcing progress when embedding Syndicate in
contexts that don't expose turn semantics.
2024-04-24 16:11:17 +02:00
Emery Hemingway 5fc371d187 Require newer Preserves 2024-04-24 16:10:34 +02:00
3 changed files with 41 additions and 15 deletions

View File

@ -55,6 +55,23 @@
"srcDir": "",
"url": "https://github.com/ehmry/hashlib/archive/f9455d4be988e14e3dc7933eb7cc7d7c4820b7ac.tar.gz"
},
{
"date": "2024-04-22T13:22:01+02:00",
"deepClone": false,
"fetchLFS": false,
"fetchSubmodules": true,
"hash": "sha256-ROpWQYIhgDRJAOJd1dAGkJCVxI2Tz8xoHYjLTQDfXaA=",
"leaveDotGit": false,
"method": "git",
"packages": [
"preserves"
],
"path": "/nix/store/ichqy1plhjd6yql7y3dh540cshq07xv7-preserves-nim",
"rev": "fd498c6457cb9ad2f3179daa40da69eec00326dd",
"sha256": "182xvw04vjw83mlcrkwkip29b44h0v8dapg2014k9011h90mdsj4",
"srcDir": "src",
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim.git"
},
{
"method": "fetchzip",
"packages": [
@ -77,17 +94,6 @@
"srcDir": "src",
"url": "https://github.com/zevv/npeg/archive/ec0cc6e64ea4c62d2aa382b176a4838474238f8d.tar.gz"
},
{
"method": "fetchzip",
"packages": [
"preserves"
],
"path": "/nix/store/2hy124xgabz134dxj3wji7mp47fdwy3w-source",
"rev": "9ae435a83c6d5028405538af5d24a023af625b6e",
"sha256": "1k7ywcp1a53x2fpc6wc2b0qzb264dkifash0s1wcp66rw3lx15k2",
"srcDir": "src",
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim/archive/9ae435a83c6d5028405538af5d24a023af625b6e.tar.gz"
},
{
"method": "fetchzip",
"packages": [

View File

@ -147,7 +147,11 @@ when tracing:
method publish*(e: Entity; turn: var Turn; v: AssertionRef; h: Handle) {.base.} = discard
method retract*(e: Entity; turn: var Turn; h: Handle) {.base.} = discard
method message*(e: Entity; turn: var Turn; v: AssertionRef) {.base.} = discard
method sync*(e: Entity; turn: var Turn; peer: Cap) {.base.} = discard
proc message*(turn: var Turn; r: Cap; v: Value)
method sync*(e: Entity; turn: var Turn; peer: Cap) {.base.} =
message(turn, peer, true.toPreserves)
converter toActor(f: Facet): Actor = f.actor
converter toActor(t: Turn): Actor = t.facet.actor
@ -736,8 +740,24 @@ proc runPendingTurns* =
terminateActor(turn, err)
raise err
proc runOnce*: bool {.discardable.} =
## Run pending turns if there are any, otherwise
## poll for external events and run any resulting turns.
## Return true if any turns have been processed.
if turnQueue.len == 0:
when defined(solo5):
discard solo5_dispatcher.runOnce()
else:
var ready: seq[Continuation]
ioqueue.poll(ready)
while ready.len > 0:
discard trampoline:
ready.pop()
result = turnQueue.len > 0
runPendingTurns()
proc run* =
## Run actors to completion
## Run actors to completion.
when defined(solo5):
while turnQueue.len > 0 or solo5_dispatcher.runOnce():
runPendingTurns()

View File

@ -1,6 +1,6 @@
# Package
version = "20240421"
version = "20240424"
author = "Emery Hemingway"
description = "Syndicated actors for conversational concurrency"
license = "Unlicense"
@ -9,4 +9,4 @@ srcDir = "src"
# Dependencies
requires "https://github.com/ehmry/hashlib.git >= 20231130", "nim >= 2.0.0", "https://git.syndicate-lang.org/ehmry/preserves-nim.git >= 20240312", "https://github.com/ehmry/nim-sys.git#4ef3b624db86e331ba334e705c1aa235d55b05e1", "https://git.sr.ht/~ehmry/nim_taps >= 20240405"
requires "https://github.com/ehmry/hashlib.git >= 20231130", "nim >= 2.0.0", "https://git.syndicate-lang.org/ehmry/preserves-nim.git >= 20240422", "https://github.com/ehmry/nim-sys.git#4ef3b624db86e331ba334e705c1aa235d55b05e1", "https://git.sr.ht/~ehmry/nim_taps >= 20240405"