mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-09 08:23:07 +00:00
rough sketch
This commit is contained in:
parent
ba54ab5f8b
commit
586582a7c7
@ -20,6 +20,7 @@ proc firstArgument*(params: NimNode): (NimNode, NimNode) =
|
|||||||
result = (ident "", newNimNode(nnkEmpty))
|
result = (ident "", newNimNode(nnkEmpty))
|
||||||
|
|
||||||
iterator paramsIter*(params: NimNode): tuple[name, ntype: NimNode] =
|
iterator paramsIter*(params: NimNode): tuple[name, ntype: NimNode] =
|
||||||
|
## iterators through the parameters
|
||||||
for i in 1 ..< params.len:
|
for i in 1 ..< params.len:
|
||||||
let arg = params[i]
|
let arg = params[i]
|
||||||
let argType = arg[^2]
|
let argType = arg[^2]
|
||||||
|
|||||||
@ -1,14 +1,30 @@
|
|||||||
|
|
||||||
|
import std/[macros, strutils]
|
||||||
|
|
||||||
|
macro asyncTask*(p: untyped): untyped =
|
||||||
|
|
||||||
|
let
|
||||||
|
procId = p[0]
|
||||||
|
procLineInfo = p.lineInfoObj
|
||||||
|
genericParams = p[2]
|
||||||
|
params = p[3]
|
||||||
|
pragmas = p[4]
|
||||||
|
body = p[6]
|
||||||
|
name = repr(procId).strip(false, true, {'*'})
|
||||||
|
|
||||||
|
echo "ASYNC_TASK: name: ", name
|
||||||
|
echo "ASYNC_TASK: params: \n", params.treeRepr
|
||||||
|
|
||||||
|
proc doHashes*(args: openArray[byte]) {.asyncTask.} =
|
||||||
|
|
||||||
|
echo "args: ", args.len()
|
||||||
|
|
||||||
|
|
||||||
proc doHashes*[T: object](args: openArray[T], obj: Object) {.asyncTask.} =
|
when false:
|
||||||
|
proc doHashesTask*(args: seq[Data]) =
|
||||||
|
discard
|
||||||
|
|
||||||
let x = args
|
proc doHashes*(args: seq[Data]) {.async.} =
|
||||||
|
|
||||||
|
|
||||||
proc doHashesTask*(args: seq[Data]) =
|
|
||||||
...
|
|
||||||
|
|
||||||
proc doHashes*(args: seq[Data]) {.async.} =
|
|
||||||
# setup signals ... etc
|
# setup signals ... etc
|
||||||
# memory stuffs
|
# memory stuffs
|
||||||
# create future
|
# create future
|
||||||
@ -20,8 +36,7 @@ proc doHashes*(args: seq[Data]) {.async.} =
|
|||||||
GC_unref(args)
|
GC_unref(args)
|
||||||
|
|
||||||
|
|
||||||
proc processHashes*(args: seq[Data]) {.async.} =
|
proc processHashes*(args: seq[Data]) {.async.} =
|
||||||
|
|
||||||
## do some processing on another thread
|
## do some processing on another thread
|
||||||
let res = await doHashes(args)
|
let res = await doHashes(args)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user