This commit is contained in:
munna0908 2025-07-02 18:59:40 +05:30
parent 8ebe766599
commit b854053a5c
No known key found for this signature in database
GPG Key ID: 2FFCD637E937D3E6

View File

@ -320,9 +320,12 @@ proc asyncEncode*(
): Future[?!seq[seq[byte]]] {.async: (raises: [CancelledError]).} =
without threadPtr =? ThreadSignalPtr.new():
return failure("Unable to create thread signal")
echo "In Async Encode"
defer:
threadPtr.close().expect("closing once works")
if threadPtr != nil:
?threadPtr.close().mapFailure()
threadPtr = nil
echo "Out Async Encode"
## Create an ecode task with block data
var task = EncodeTask(
@ -482,9 +485,12 @@ proc asyncDecode*(
): Future[?!seq[seq[byte]]] {.async: (raises: [CancelledError]).} =
without threadPtr =? ThreadSignalPtr.new():
return failure("Unable to create thread signal")
echo "In Async Decode"
defer:
threadPtr.close().expect("closing once works")
if threadPtr != nil:
?threadPtr.close().mapFailure()
threadPtr = nil
echo "Out Async Decode"
## Create an decode task with block data
var task = DecodeTask(
@ -507,12 +513,12 @@ proc asyncDecode*(
return failure(err)
defer:
task.recovered = default(Isolated[seq[seq[byte]]])
if not task.success.load():
return failure("Leopard decoding task failed")
defer:
task.recovered = default(Isolated[seq[seq[byte]]])
var recovered = task.recovered.extract
success(recovered)