make chronosim work through patchFile

patchFile is not a perfect solution, e.g. needs some
handling of circular references, but seems to work
good enough

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-06-15 11:38:50 +02:00
parent e76deb7e19
commit c9d20230bf
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
3 changed files with 15 additions and 5 deletions

View File

@ -8,9 +8,11 @@
import
std/[tables, deques, random],
chronos,
chronicles
# we can't import chronos directly, as patchFile would create a loop
import chronos/[asyncloop, asyncsync, handles, transport, timer, debugutils]
logScope:
topics = "ChronoSim"
@ -20,10 +22,10 @@ const
# chronos uses SomeIntegerI64. We shoudl be more specific here to override
proc milliseconds*(v: int): Duration {.inline.} =
chronos.milliseconds(v * timeWarp)
timer.milliseconds(v * timeWarp)
proc seconds*(v: int): Duration {.inline.} =
chronos.seconds(v * timeWarp)
timer.seconds(v * timeWarp)
when(emulateDatagram): #enable network emulator
type
@ -111,4 +113,11 @@ export seconds, milliseconds
export TransportAddress, initTAddress
export async, sleepAsync, complete, await
export Future, FutureBase, newFuture, futureContinue
export TransportOsError
export TransportOsError
# export copied from chronos, except transport
export asyncloop, asyncsync, handles, timer, debugutils
# export copied chronos/transport except what we replace
export common, stream, ipnet, osnet
export asyncstream, chunkstream

1
das.nims Normal file
View File

@ -0,0 +1 @@
patchFile("chronos", "chronos", "chronosim/chronos")

@ -1 +1 @@
Subproject commit 3afc0063423aa6b38a247a7e8399d381cdcd6f7c
Subproject commit 8b3d67688069784a5651a18f672e0b2ada74e3b7