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