This commit is contained in:
Jaremy Creechley 2023-08-24 19:02:46 -07:00 committed by Dmitriy Ryajov
parent 8644cbc9dc
commit 567e0d7003
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 4 additions and 7 deletions

View File

@ -22,10 +22,6 @@ type
# stores*: Table[Key, SharedDatastore]
tds: ThreadDatastorePtr
template newSignal(): auto =
ThreadSignalPtr.new().valueOr:
return failure newException(DatastoreError, "error creating signal")
method has*(
self: SharedDatastore,
key: Key
@ -78,13 +74,14 @@ method close*(
proc newSharedDataStore*(
# T: typedesc[SharedDatastore],
backend: ThreadBackend,
): ?!SharedDatastore =
): Future[?!SharedDatastore] {.async.} =
var
self = SharedDatastore()
res = newThreadResult(ThreadDatastorePtr)
res[].signal = newSignal()
res[].signal = ThreadSignalPtr.new().valueOr:
return failure newException(DatastoreError, "error creating signal")
res.createThreadDatastore(backend)
await wait(res[].signal)

View File

@ -23,7 +23,7 @@ type
Success
Error
ThreadResult*[T: DataBuffer | void] = object
ThreadResult*[T: DataBuffer | void | ThreadDatastorePtr] = object
state*: ThreadResultKind
signal*: ThreadSignalPtr
value*: T