mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 22:23:10 +00:00
fixup databuffer
This commit is contained in:
parent
abfd12f7a6
commit
892ec385ee
@ -27,8 +27,10 @@ proc `=destroy`*(x: var DataBufferHolder) =
|
||||
# echo "buffer: FREE: ", repr x.buf.pointer
|
||||
deallocShared(x.buf)
|
||||
|
||||
proc len*(a: DataBuffer): int = a[].size
|
||||
proc capacity*(a: DataBuffer): int = a[].cap
|
||||
proc len*(a: DataBuffer): int =
|
||||
if a.isNil: 0 else: a[].size
|
||||
proc capacity*(a: DataBuffer): int =
|
||||
if a.isNil: 0 else: a[].cap
|
||||
|
||||
proc isNil*(a: DataBuffer): bool = smartptrs.isNil(a)
|
||||
|
||||
|
||||
@ -242,7 +242,7 @@ proc queryTask[DB](
|
||||
(?!QResult).err(qh.error())
|
||||
else:
|
||||
# otherwise manually an set empty ok result
|
||||
ctx[].res.ok (KeyId.none, DataBuffer.new())
|
||||
ctx[].res.ok (KeyId.none, DataBuffer(), )
|
||||
discard ctx[].signal.fireSync()
|
||||
|
||||
var handle = qh.get()
|
||||
@ -260,7 +260,7 @@ proc queryTask[DB](
|
||||
discard ctx[].signal.fireSync()
|
||||
|
||||
# set final result
|
||||
(?!QResult).ok((KeyId.none, DataBuffer.new()))
|
||||
(?!QResult).ok((KeyId.none, DataBuffer()))
|
||||
|
||||
method query*(
|
||||
self: ThreadDatastore,
|
||||
@ -313,16 +313,17 @@ method query*(
|
||||
iter.next = next
|
||||
return success iter
|
||||
|
||||
proc new*(
|
||||
self: type ThreadDatastore,
|
||||
ds: Datastore,
|
||||
withLocks = static false,
|
||||
tp: Taskpool): ?!ThreadDatastore =
|
||||
proc new*(self: type ThreadDatastore,
|
||||
backend: ThreadBackendKinds,
|
||||
withLocks = static false,
|
||||
tp: Taskpool
|
||||
): ?!ThreadDatastore =
|
||||
doAssert tp.numThreads > 1, "ThreadDatastore requires at least 2 threads"
|
||||
|
||||
success ThreadDatastore(
|
||||
tp: tp,
|
||||
ds: ds,
|
||||
ds: ThreadBackend(),
|
||||
withLocks: withLocks,
|
||||
queryLock: newAsyncLock(),
|
||||
semaphore: AsyncSemaphore.new(tp.numThreads - 1))
|
||||
semaphore: AsyncSemaphore.new(tp.numThreads - 1)
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user