mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-02 13:43:11 +00:00
it runs!
This commit is contained in:
parent
92b6599396
commit
8a36bbbdb2
@ -23,4 +23,6 @@ proc get*[T](self: Datastore2[T], key: KeyBuffer): ?!ValueBuffer {.nimcall.} =
|
||||
proc put*[T](self: Datastore2[T], key: KeyBuffer, data: ValueBuffer): ?!void {.nimcall.} =
|
||||
self.put(self.ids, key, data)
|
||||
proc close*[T](self: Datastore2[T]): ?!void {.nimcall.} =
|
||||
echo "CLOSE: ", self
|
||||
echo "CLOSE: ", self.ids.repr
|
||||
self.close(self.ids)
|
||||
|
||||
@ -105,13 +105,13 @@ method put*[T](
|
||||
await sig.acquireSig()
|
||||
|
||||
let ret = newSharedPtr(ThreadResult[void])
|
||||
proc submitPut(): ?!void =
|
||||
proc submitPut() =
|
||||
let bkey = KeyBuffer.new(key)
|
||||
let bval = DataBuffer.new(data)
|
||||
# queue taskpool work
|
||||
self.tds[].tp.spawn putTask(sig, ret, self.tds, bkey, bval)
|
||||
|
||||
submitPut().get()
|
||||
submitPut()
|
||||
await sig.wait()
|
||||
return ret.convert(void)
|
||||
|
||||
@ -188,7 +188,7 @@ method close*[T](
|
||||
): Future[?!void] {.async.} =
|
||||
# TODO: how to handle failed close?
|
||||
result = success()
|
||||
? close(self.tds[].ds)
|
||||
close(self.tds[].ds).get()
|
||||
|
||||
if self.tds[].tp != nil:
|
||||
## this can block... how to handle? maybe just leak?
|
||||
|
||||
@ -30,10 +30,10 @@ proc testThreadProxy() =
|
||||
key1 = Key.init("/a").tryGet
|
||||
data = "value for 1".toBytes()
|
||||
|
||||
teardownAll:
|
||||
let res = await sds.close()
|
||||
res.get()
|
||||
echo "teardown done"
|
||||
# teardownAll:
|
||||
# let res = await sds.close()
|
||||
# res.get()
|
||||
# echo "teardown done"
|
||||
|
||||
test "check put":
|
||||
# echo "\n\n=== put ==="
|
||||
@ -52,6 +52,7 @@ proc testThreadProxy() =
|
||||
for c in res2.get():
|
||||
val &= char(c)
|
||||
# print "get res2: ", $val
|
||||
GC_fullCollect()
|
||||
|
||||
proc testThreadProxyBasics() =
|
||||
suite "Test Basics":
|
||||
@ -71,6 +72,7 @@ proc testThreadProxyBasics() =
|
||||
# # print "res3: ", res3
|
||||
|
||||
basicStoreTests(sds, key, bytes, otherBytes)
|
||||
GC_fullCollect()
|
||||
|
||||
# proc testThreadProxyQuery() =
|
||||
# suite "Test Query":
|
||||
@ -105,6 +107,7 @@ when isMainModule:
|
||||
for i in 1..100:
|
||||
testThreadProxy()
|
||||
testThreadProxyBasics()
|
||||
GC_fullCollect()
|
||||
# testThreadProxyQuery()
|
||||
else:
|
||||
testThreadProxy()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user