switch to result type

This commit is contained in:
Jaremy Creechley 2023-08-29 14:43:05 -07:00 committed by Dmitriy Ryajov
parent 5f13765a49
commit 7a3c64d425
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
2 changed files with 6 additions and 10 deletions

View File

@ -37,7 +37,6 @@ method has*(
has(ret, self.tds, key)
await wait(ret[].signal)
finally:
# echo "closing signal"
ret[].signal.close()
# echo "\nSharedDataStore:has:value: ", ret[].repr
@ -55,7 +54,6 @@ method delete*(
delete(ret, self.tds, key)
await wait(ret[].signal)
finally:
# echo "closing signal"
ret[].signal.close()
# echo "\nSharedDataStore:put:value: ", ret[].repr
@ -105,7 +103,6 @@ method put*(
finally:
ret[].signal.close()
# echo "\nSharedDataStore:put:value: ", ret[].repr
return success()
method put*(
@ -133,17 +130,16 @@ method close*(
## this can block... how to handle? maybe just leak?
self.tds[].tp.shutdown()
proc newSharedDataStore*(
proc newThreadProxyDatastore*(
ds: Datastore,
): ?!ThreadProxyDatastore =
## create a new
var self = ThreadProxyDatastore()
let value = newSharedPtr(ThreadDatastore)
echo "\nnewDataStore: threadId:", getThreadId()
# GC_ref(ds)
value[].ds = ds
# GC_ref(ds) ## TODO: is this needed?
try:
value[].ds = ds
value[].tp = Taskpool.new(num_threads = 2)
except Exception as exc:
return err((ref DatastoreError)(msg: exc.msg))

View File

@ -27,7 +27,7 @@ suite "Test Basic ThreadProxyDatastore":
setupAll:
mem = MemoryDatastore.new()
sds = newSharedDataStore(mem).expect("should work")
sds = newThreadProxyDatastore(mem).expect("should work")
key1 = Key.init("/a").tryGet
data = "value for 1".toBytes()
@ -62,7 +62,7 @@ suite "Test Basic ThreadProxyDatastore":
setupAll:
memStore = MemoryDatastore.new()
ds = newSharedDataStore(memStore).expect("should work")
ds = newThreadProxyDatastore(memStore).expect("should work")
teardownAll:
(await memStore.close()).get()