This commit is contained in:
Jaremy Creechley 2023-09-19 20:59:20 -07:00
parent 8a36bbbdb2
commit 13dc326494
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
4 changed files with 7 additions and 9 deletions

View File

@ -11,7 +11,7 @@ type
delete*: proc(self: SharedPtr[T], key: KeyBuffer): ?!void {.nimcall, gcsafe, raises: [].}
get*: proc(self: SharedPtr[T], key: KeyBuffer): ?!ValueBuffer {.nimcall, gcsafe, raises: [].}
put*: proc(self: SharedPtr[T], key: KeyBuffer, data: ValueBuffer): ?!void {.nimcall, gcsafe, raises: [].}
close*: proc(self: SharedPtr[T]): ?!void {.gcsafe, raises: [].}
close*: proc(self: SharedPtr[T]): ?!void {.nimcall, gcsafe, raises: [].}
ids*: SharedPtr[T]
proc has*[T](self: Datastore2[T], key: KeyBuffer): ?!bool =
@ -23,6 +23,4 @@ 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)

View File

@ -24,7 +24,7 @@ push: {.upraises: [].}
type
MemoryDatastore* = object
lock*: Lock
store*: SimpleTable[10_000]
store*: SimpleTable[100]
proc has(self: SharedPtr[MemoryDatastore], key: KeyBuffer): ?!bool =

View File

@ -193,7 +193,7 @@ method close*[T](
if self.tds[].tp != nil:
## this can block... how to handle? maybe just leak?
self.tds[].tp.shutdown()
self[].tds[].tp = nil # ensure our sharedptr doesn't try and dealloc
# self[].tds[].tp = nil # ensure our sharedptr doesn't try and dealloc
self.tds.release()
echo "close done"

View File

@ -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 ==="