mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-04 14:43:12 +00:00
move into their own threads folder
This commit is contained in:
parent
c9405b0618
commit
2f3449e92c
@ -7,8 +7,8 @@ import pkg/questionable/results
|
||||
|
||||
import ./key
|
||||
import ./types
|
||||
import ./databuffer
|
||||
import ./threadresults
|
||||
import ./threads/databuffer
|
||||
import ./threads/threadresults
|
||||
export options, SortOrder
|
||||
|
||||
type
|
||||
|
||||
@ -12,8 +12,7 @@ import pkg/threading/smartptrs
|
||||
import ./key
|
||||
import ./query
|
||||
import ./datastore
|
||||
import ./threadbackend
|
||||
import ./fsds
|
||||
import ./threads/threadbackend
|
||||
|
||||
export key, query
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ proc toBuffer*(err: ref Exception): CatchableErrorBuffer =
|
||||
msg: StringBuffer.new(err.msg)
|
||||
)
|
||||
|
||||
import ./key
|
||||
import ../key
|
||||
import stew/results
|
||||
|
||||
proc new*(tp: typedesc[KeyBuffer], key: Key): KeyBuffer =
|
||||
@ -7,8 +7,8 @@ import pkg/upraises
|
||||
import pkg/taskpools
|
||||
import pkg/threading/smartptrs
|
||||
|
||||
import ./key
|
||||
import ./query
|
||||
import ../key
|
||||
import ../query
|
||||
import ./datastore
|
||||
import ./databuffer
|
||||
import ./threadresults
|
||||
@ -44,8 +44,8 @@ type
|
||||
##
|
||||
|
||||
const
|
||||
SignalPoolSize {.intdefine.} = 1024
|
||||
SignalPoolRetries {.intdefine.} = 1000
|
||||
SignalPoolSize {.intdefine.} = 10
|
||||
SignalPoolRetries {.intdefine.} = 10
|
||||
|
||||
var
|
||||
signalPoolLock: Lock
|
||||
@ -84,13 +84,13 @@ proc getThreadSignal*(): Future[ThreadSignalPtr] {.async, raises: [].} =
|
||||
if signalPoolFree.len() > 0:
|
||||
let res = signalPoolFree.pop()
|
||||
signalPoolUsed.incl(res)
|
||||
echo "get:signalPoolUsed:size: ", signalPoolUsed.len()
|
||||
# echo "get:signalPoolUsed:size: ", signalPoolUsed.len()
|
||||
return res
|
||||
except KeyError:
|
||||
discard
|
||||
finally:
|
||||
signalPoolLock.release()
|
||||
echo "wait:signalPoolUsed: "
|
||||
# echo "wait:signalPoolUsed: "
|
||||
await sleepAsync(10.milliseconds)
|
||||
raise newException(DeadThreadDefect, "reached limit trying to acquire a ThreadSignalPtr")
|
||||
|
||||
@ -100,7 +100,7 @@ proc release*(sig: ThreadSignalPtr) {.raises: [].} =
|
||||
withLock(signalPoolLock):
|
||||
signalPoolUsed.excl(sig)
|
||||
signalPoolFree.incl(sig)
|
||||
echo "free:signalPoolUsed:size: ", signalPoolUsed.len()
|
||||
# echo "free:signalPoolUsed:size: ", signalPoolUsed.len()
|
||||
|
||||
proc threadSafeType*[T: ThreadSafeTypes](tp: typedesc[T]) =
|
||||
## Used to explicitly mark a type as threadsafe. It's checked
|
||||
Loading…
x
Reference in New Issue
Block a user