This commit is contained in:
Jaremy Creechley 2024-02-16 15:15:21 -07:00
parent 34df48f369
commit e7191ad930
2 changed files with 18 additions and 3 deletions

View File

@ -18,7 +18,18 @@ logScope:
## This module provides a simple way to submit jobs to taskpools
## and getting a result returned via an async future.
##
##
## Any compatible arguments of `seq[T]` or `string` args passed
## via the `submit` macro will be converted into the special `OpenArrayHolder[T]` type.
## The `submit` macro converts these arguments in this object and retains the
## memory associated with the original `seq[T]` or `string` object.
## This greatly simplifies the passing of these these types in `refc`.
##
## Note, for `arc` or `orc` GC's this setup will be replaced with a move operation in the future.
## These GC's also allow greater support for moving GC types across thread boundaries.
##
## Currently this module limits support for GC types to ensure `refc` safety.
##
type
JobQueue*[T] = ref object ## job queue object

View File

@ -15,7 +15,7 @@ export jobs
## .. code-block::
## proc doHashes*(data: openArray[byte], opts: HashOptions): float {.asyncTask.} =
## result = 10.0
##
##
## .. code-block::
## proc doHashesTasklet*(data: openArray[byte]; opts: HashOptions): float {.nimcall.} =
@ -26,7 +26,11 @@ export jobs
## let val {.inject.} = doHashesTasklet(convertParamType(data),
## convertParamType(opts))
## discard jobResult.queue.send((jobResult.id, val))
##
## Paramters with type of `openArray[T]` have special support and are converted
## into the `OpenArrayHolder[T]` type from the jobs module. See the jobs module
## for more information.
##
template convertParamType*[T](obj: OpenArrayHolder[T]): auto =
static:
echo "CONVERTPARAMTYPE:: ", $typeof(obj)