CAPI app stopping #1521
-
uWebSockets C++ library has way to safely stop server by scheduling socket closing with code like that.
Does CAPI has a similar or another way to stop the app? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
In my case i just use libuv to defer to me the close call, loop defer its not yet on C API. You can get the native loop using: struct us_loop_t *uws_get_loop();
struct us_loop_t *uws_get_loop_with_native(void* existing_native_loop);
uv_loop_t *loop = (uv_loop_t *loop)uws_get_loop_with_native(uv_default_loop()); or uv_loop_t *loop = ( uv_loop_t *)uws_get_loop(); and after this you can use any API of libuv like uv_prepare to close the API before pooling more IO, or uv_check to close the API after pooling more IO, if you want to call this from another thread (remembers that you can only have 1 App/SSLApp per thread) you can use async to wakeup the event loop in main thread and close to you but libuv is not the only loop option, so i think is a good idea to add defer to CAPI in future |
Beta Was this translation helpful? Give feedback.
@gigagrig
In my case i just use libuv to defer to me the close call, loop defer its not yet on C API.
You can get the native loop using:
uws_get_loop_with_native
basically sets you the event loop and returns to youor
and after this you can use any API of libuv like uv_prepare to close the API before pooling more IO, or uv_check to close the API after pooling more IO, if you want to call this from another thread (remembers that you can only ha…