Can i run mg_mgr_poll in the main thread and not be blocked ? #2147
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don't have the slightest idea of what Unreal Engine is. |
Beta Was this translation helpful? Give feedback.
-
Hello, For anyone bumping here and using Unreal, from a practical point of view the solution is really simple.
Thanks |
Beta Was this translation helpful? Give feedback.
I don't have the slightest idea of what Unreal Engine is.
Mongoose select()s or poll()s waiting for data or timeout (user defined, so...). If you run another stuff in the same loop, it must be non-blocking and will be delayed by Mongoose's own blocking (timeout).
If you need to communicate with other threads you can use its internal queue (latest) or its back-to-back socket connection (to be deprecated in the future) (or a queue, or shared variables, or OS messages, or whatever)
https://github.com/cesanta/mongoose/tree/master/examples/multi-threaded (the example shows using Mongoose internal lock-free queue)
https://mongoose.ws/documentation/tutorials/multi-threaded/ (the tutorial covers …