Add gcsafe pragma

This commit is contained in:
Arnaud 2024-12-18 16:36:55 +01:00
parent 34f5e0071c
commit 7c9b607e38
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
6 changed files with 20 additions and 20 deletions

View File

@ -48,7 +48,7 @@ when isMainModule:
let config = CodexConf.load(
version = codexFullVersion,
envVarsPrefix = "codex",
secondarySources = proc (config: CodexConf, sources: auto) =
secondarySources = proc (config: CodexConf, sources: auto) {.gcsafe, raises: [ConfigurationError].} =
if configFile =? config.configFile:
sources.addConfigFile(Toml, configFile)
)

View File

@ -8,7 +8,7 @@ type
SecondsSince1970* = int64
Timeout* = object of CatchableError
method now*(clock: Clock): SecondsSince1970 {.base, upraises: [].} =
method now*(clock: Clock): SecondsSince1970 {.base, gcsafe, upraises: [].} =
raiseAssert "not implemented"
method waitUntil*(clock: Clock, time: SecondsSince1970) {.base, async.} =

View File

@ -124,7 +124,7 @@ method provide*(d: Discovery, host: ca.Address) {.async, base.} =
method removeProvider*(
d: Discovery,
peerId: PeerId): Future[void] {.base.} =
peerId: PeerId): Future[void] {.base, gcsafe.} =
## Remove provider from providers table
##

View File

@ -22,7 +22,7 @@ type
EncoderBackend* = ref object of ErasureBackend
DecoderBackend* = ref object of ErasureBackend
method release*(self: ErasureBackend) {.base.} =
method release*(self: ErasureBackend) {.base, gcsafe.} =
## release the backend
##
raiseAssert("not implemented!")
@ -31,7 +31,7 @@ method encode*(
self: EncoderBackend,
buffers,
parity: var openArray[seq[byte]]
): Result[void, cstring] {.base.} =
): Result[void, cstring] {.base, gcsafe.} =
## encode buffers using a backend
##
raiseAssert("not implemented!")
@ -41,7 +41,7 @@ method decode*(
buffers,
parity,
recovered: var openArray[seq[byte]]
): Result[void, cstring] {.base.} =
): Result[void, cstring] {.base, gcsafe.} =
## decode buffers using a backend
##
raiseAssert("not implemented!")

View File

@ -33,13 +33,13 @@ type
BlockStore* = ref object of RootObj
onBlockStored*: ?CidCallback
method getBlock*(self: BlockStore, cid: Cid): Future[?!Block] {.base.} =
method getBlock*(self: BlockStore, cid: Cid): Future[?!Block] {.base, gcsafe.} =
## Get a block from the blockstore
##
raiseAssert("getBlock by cid not implemented!")
method getBlock*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!Block] {.base.} =
method getBlock*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!Block] {.base, gcsafe.} =
## Get a block from the blockstore
##
@ -50,13 +50,13 @@ method getCid*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!Cid] {.
##
raiseAssert("getCid by treecid not implemented!")
method getBlock*(self: BlockStore, address: BlockAddress): Future[?!Block] {.base.} =
method getBlock*(self: BlockStore, address: BlockAddress): Future[?!Block] {.base, gcsafe.} =
## Get a block from the blockstore
##
raiseAssert("getBlock by addr not implemented!")
method getBlockAndProof*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!(Block, CodexProof)] {.base.} =
method getBlockAndProof*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!(Block, CodexProof)] {.base, gcsafe.} =
## Get a block and associated inclusion proof by Cid of a merkle tree and an index of a leaf in a tree
##
@ -65,7 +65,7 @@ method getBlockAndProof*(self: BlockStore, treeCid: Cid, index: Natural): Future
method putBlock*(
self: BlockStore,
blk: Block,
ttl = Duration.none): Future[?!void] {.base.} =
ttl = Duration.none): Future[?!void] {.base, gcsafe.} =
## Put a block to the blockstore
##
@ -76,7 +76,7 @@ method putCidAndProof*(
treeCid: Cid,
index: Natural,
blockCid: Cid,
proof: CodexProof): Future[?!void] {.base.} =
proof: CodexProof): Future[?!void] {.base, gcsafe.} =
## Put a block proof to the blockstore
##
@ -85,7 +85,7 @@ method putCidAndProof*(
method getCidAndProof*(
self: BlockStore,
treeCid: Cid,
index: Natural): Future[?!(Cid, CodexProof)] {.base.} =
index: Natural): Future[?!(Cid, CodexProof)] {.base, gcsafe.} =
## Get a block proof from the blockstore
##
@ -94,7 +94,7 @@ method getCidAndProof*(
method ensureExpiry*(
self: BlockStore,
cid: Cid,
expiry: SecondsSince1970): Future[?!void] {.base.} =
expiry: SecondsSince1970): Future[?!void] {.base, gcsafe.} =
## Ensure that block's assosicated expiry is at least given timestamp
## If the current expiry is lower then it is updated to the given one, otherwise it is left intact
##
@ -105,7 +105,7 @@ method ensureExpiry*(
self: BlockStore,
treeCid: Cid,
index: Natural,
expiry: SecondsSince1970): Future[?!void] {.base.} =
expiry: SecondsSince1970): Future[?!void] {.base, gcsafe.} =
## Ensure that block's associated expiry is at least given timestamp
## If the current expiry is lower then it is updated to the given one, otherwise it is left intact
##
@ -124,13 +124,13 @@ method delBlock*(self: BlockStore, treeCid: Cid, index: Natural): Future[?!void]
raiseAssert("delBlock not implemented!")
method hasBlock*(self: BlockStore, cid: Cid): Future[?!bool] {.base.} =
method hasBlock*(self: BlockStore, cid: Cid): Future[?!bool] {.base, gcsafe.} =
## Check if the block exists in the blockstore
##
raiseAssert("hasBlock not implemented!")
method hasBlock*(self: BlockStore, tree: Cid, index: Natural): Future[?!bool] {.base.} =
method hasBlock*(self: BlockStore, tree: Cid, index: Natural): Future[?!bool] {.base, gcsafe.} =
## Check if the block exists in the blockstore
##
@ -138,13 +138,13 @@ method hasBlock*(self: BlockStore, tree: Cid, index: Natural): Future[?!bool] {.
method listBlocks*(
self: BlockStore,
blockType = BlockType.Manifest): Future[?!AsyncIter[?Cid]] {.base.} =
blockType = BlockType.Manifest): Future[?!AsyncIter[?Cid]] {.base, gcsafe.} =
## Get the list of blocks in the BlockStore. This is an intensive operation
##
raiseAssert("listBlocks not implemented!")
method close*(self: BlockStore): Future[void] {.base.} =
method close*(self: BlockStore): Future[void] {.base, gcsafe.} =
## Close the blockstore, cleaning up resources managed by it.
## For some implementations this may be a no-op
##

View File

@ -40,7 +40,7 @@ proc timerLoop(timer: Timer) {.async.} =
except CatchableError as exc:
error "Timer caught unhandled exception: ", name=timer.name, msg=exc.msg
method start*(timer: Timer, callback: TimerCallback, interval: Duration) {.base.} =
method start*(timer: Timer, callback: TimerCallback, interval: Duration) {.gcsafe, base.} =
if timer.loopFuture != nil:
return
trace "Timer starting: ", name=timer.name