[Libwebsockets] Execute callback on event loop thread
kiv.apple at gmail.com
Sat Jul 24 01:34:58 CEST 2021
I have two threads in my application: the first is doing my own stuff and
the second is running a loop with a lws_service call. And sometimes I want
to send some data via WebSocket from the first thread. But WebSockets API
is not thread-safe as I understand, so I want to execute some callback
which will do actual sending on the event loop thread. Like as uv_async_t
in libuv can do that.
Is there any API in libwebsockets which allows it to execute some callback
on event loop thread? Or is there a possibility to obtain a uv_loop_t
instance to use uv_async_t? (I am using libwebsockets with libuv support
The another solution came to my mind also - use lws_sul_schedule to
schedule my callback within one microsecond, but it seems to be not
thread-safe too if libwebsockets compiled without SMP support (and SMP
cannot be enabled without pthread library which is not available on Win32
MSVC target which is one of these I am compiling - I am using threading
support from libuv in my program, so I have no dependency on pthread).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libwebsockets