mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-19 01:12:34 +00:00
fix results stuff
This commit is contained in:
parent
ebc284ae6a
commit
0bbd558ee7
@ -64,10 +64,6 @@ proc prove*[H](
|
||||
let res: ?!CircomProof = failure(err)
|
||||
return res
|
||||
|
||||
let sigRes = signal.close()
|
||||
if sigRes.isErr:
|
||||
return failure(sigRes.error())
|
||||
|
||||
let pf: CircomProof = proof
|
||||
success(pf)
|
||||
|
||||
|
@ -12,15 +12,22 @@ const
|
||||
proc awaitThreadResult*[T](signal: ThreadSignalPtr, handle: Flowvar[T]): Future[?!T] {.async.} =
|
||||
await wait(signal)
|
||||
|
||||
proc closeSig() =
|
||||
let sigRes = signal.close()
|
||||
if sigRes.isErr:
|
||||
return failure(sigRes.error())
|
||||
|
||||
var
|
||||
res: T
|
||||
awaitTotal: Duration
|
||||
|
||||
while awaitTotal < CompletionTimeout:
|
||||
if handle.tryComplete(res):
|
||||
if handle.tryComplete(res): ## TODO: pretty sure this leaks currently
|
||||
closeSig()
|
||||
return success(res)
|
||||
else:
|
||||
awaitTotal += CompletionRetryDelay
|
||||
await sleepAsync(CompletionRetryDelay)
|
||||
|
||||
closeSig()
|
||||
return failure("Task signaled finish but didn't return any result within " & $CompletionRetryDelay)
|
||||
|
Loading…
x
Reference in New Issue
Block a user