mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 14:33:12 +00:00
calling the GC when destrouying nodes
This commit is contained in:
parent
d5f18cf455
commit
1090b6018f
@ -183,6 +183,17 @@ proc waku_destroy(
|
||||
initializeLibrary()
|
||||
checkLibwakuParams(ctx, callback, userData)
|
||||
|
||||
let retCode = handleRequest(
|
||||
ctx,
|
||||
RequestType.LIFECYCLE,
|
||||
NodeLifecycleRequest.createShared(NodeLifecycleMsgType.DESTROY_NODE, nil, nil),
|
||||
callback,
|
||||
userData,
|
||||
)
|
||||
|
||||
if retCode != RET_OK:
|
||||
return RET_ERR
|
||||
|
||||
waku_thread.destroyWakuThread(ctx).isOkOr:
|
||||
let msg = "libwaku error: " & $error
|
||||
callback(RET_ERR, unsafeAddr msg[0], cast[csize_t](len(msg)), userData)
|
||||
@ -191,6 +202,8 @@ proc waku_destroy(
|
||||
## always need to invoke the callback although we don't retrieve value to the caller
|
||||
callback(RET_OK, nil, 0, userData)
|
||||
|
||||
echo "----------- calling GC_fullCollect in host thread"
|
||||
GC_fullCollect()
|
||||
return RET_OK
|
||||
|
||||
proc waku_version(
|
||||
|
||||
@ -14,6 +14,7 @@ type NodeLifecycleMsgType* = enum
|
||||
CREATE_NODE
|
||||
START_NODE
|
||||
STOP_NODE
|
||||
DESTROY_NODE
|
||||
|
||||
type NodeLifecycleRequest* = object
|
||||
operation: NodeLifecycleMsgType
|
||||
@ -99,5 +100,8 @@ proc process*(
|
||||
except Exception:
|
||||
error "STOP_NODE failed", error = getCurrentExceptionMsg()
|
||||
return err("exception stopping node: " & getCurrentExceptionMsg())
|
||||
of DESTROY_NODE:
|
||||
echo "----------- calling GC_fullCollect in waku thread"
|
||||
GC_fullCollect()
|
||||
|
||||
return ok("")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user