combining together

This commit is contained in:
Jaremy Creechley 2024-02-13 22:36:25 -07:00
parent 834f54b8ba
commit 14d65a5060
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300

View File

@ -33,20 +33,23 @@ macro asyncTask*(p: untyped): untyped =
params, body)
var asyncBody = newStmtList()
let tcall = newCall(ident name)
let tcall = newCall(ident(name & "Tasklet"))
for paramId, paramType in paramsIter(params):
echo "param: ", paramId, " tp: ", paramType.treeRepr
tcall.add newCall("checkParamType", paramId)
asyncBody.add tcall
asyncBody.add quote do:
let res = `tcall`
var asyncParams = params.copyNimTree()
let retType = if not hasReturnType(params): ident"void"
else: params.getReturnType()
echo "RETTYPE: ", retType.repr
# let jobRes = genSym(nskLet, "jobRes")
# asyncParams.insert(0, )
let jobArg = nnkIdentDefs.newTree(
ident"jobResult",
nnkBracketExpr.newTree(ident"JobResult", retType),
newEmptyNode()
)
asyncParams.insert(1, jobArg)
let fn = mkProc(procId, asyncParams, asyncBody)
# echo "asyncTask:fn:body:\n", fn.treerepr
result = newStmtList()
@ -61,11 +64,11 @@ type
proc doHashes*(data: openArray[byte],
opts: HashOptions) {.asyncTask.} =
discard
echo "hashing"
proc doHashes2*(data: openArray[byte],
opts: HashOptions): float {.asyncTask.} =
discard
echo "hashing"
# proc doHashesRes*(data: openArray[byte],
# opts: HashOptions): int {.asyncTask.} =