From e7191ad9300886ca870e2a9d272aa10a35a51176 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Fri, 16 Feb 2024 15:15:21 -0700 Subject: [PATCH] docs --- src/apatheia/jobs.nim | 13 ++++++++++++- src/apatheia/tasks.nim | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/apatheia/jobs.nim b/src/apatheia/jobs.nim index 38fbf2e..cf14680 100644 --- a/src/apatheia/jobs.nim +++ b/src/apatheia/jobs.nim @@ -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 diff --git a/src/apatheia/tasks.nim b/src/apatheia/tasks.nim index e970f35..0c6a79e 100644 --- a/src/apatheia/tasks.nim +++ b/src/apatheia/tasks.nim @@ -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)