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