diff --git a/.gitignore b/.gitignore index 63fd092..ea03a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ * !*/ !*.* -.tool-versions \ No newline at end of file +.tool-versions +nim.cfg diff --git a/apatheia.nimble b/apatheia.nimble index 5690a19..b318d51 100644 --- a/apatheia.nimble +++ b/apatheia.nimble @@ -10,3 +10,4 @@ srcDir = "src" requires "chronos >= 4.0.0" requires "threading" +requires "taskpool" diff --git a/src/apatheia/macroutils.nim b/src/apatheia/macroutils.nim index 16b5997..2f45207 100644 --- a/src/apatheia/macroutils.nim +++ b/src/apatheia/macroutils.nim @@ -32,9 +32,6 @@ iterator paramsIter*(params: NimNode): tuple[name, ntype: NimNode] = for j in 0 ..< arg.len-2: yield (arg[j], argType) -proc identPub*(name: string): NimNode = - result = nnkPostfix.newTree(newIdentNode("*"), ident name) - proc signalTuple*(sig: NimNode): NimNode = let otp = nnkEmpty.newTree() # echo "signalObjRaw:sig1: ", sig.treeRepr @@ -120,6 +117,16 @@ proc mkParamsType*(paramsIdent, paramsType, params, genericParams: NimNode): Nim result[0][1] = genericParams.copyNimTree() # echo "mkParamsType: ", genericParams.treeRepr +proc identPub*(name: string): NimNode = + result = nnkPostfix.newTree(newIdentNode("*"), ident name) + +proc procIdentAppend*(id: NimNode, name: string): NimNode = + if id.kind == nnkPostfix: + echo "PROC ID: ", id.treeRepr + result = id + result[1] = ident(result[1].strVal & name) + else: + result = ident(result.strVal & name) proc mkCall*(callName, params: NimNode): NimNode = ## Create local variables for each parameter in the actual RPC call proc diff --git a/src/apatheia/tasks.nim b/src/apatheia/tasks.nim index ad7da62..1199377 100644 --- a/src/apatheia/tasks.nim +++ b/src/apatheia/tasks.nim @@ -31,14 +31,17 @@ macro asyncTask*(p: untyped): untyped = for paramId, paramType in paramsIter(params): echo "param: ", paramId, " tp: ", paramType.treeRepr asyncBody.add newCall("checkParamType", paramId) + let tcall = mkCall(ident name, params) # echo "asyncTask:checks:\n", asyncBody.repr - # let tcall = mkCall(ident"tester", params) - + # echo "asyncTask:tcall: ", tcall.repr + + echo "asyncTask:body:\n", body.repr - let taskProc = mkProc(procId, params, body) + let tp = mkProc(procId.procIdentAppend("Tasklet"), + params, body) result = newStmtList() - result.add taskProc + result.add tp echo "asyncTask:body:\n", result.repr # echo "asyncTask:body:\n", result.treeRepr diff --git a/tests/test1.nim b/tests/test1.nim index 15524c4..34a96e9 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -7,7 +7,7 @@ import unittest -import apatheia/queues +import apatheia/tasks test "can add": check 10 == 10