HI, I'm trying to figure out if it's thread safe to call mg_ws_write from a completely different thread than the thread doing the reads.
I read through a bunch of issues/questions here and my guess so far is that this is fine. It seems that the websocket send events fire on the poll event. Presumably, as long as I'm mg_ws_write ing from the same thread, I don't think it could have any async issues.
However, then I saw this comment:
#139 (comment)
-
Would be any issues calling mg_ws_write without dealing with thread safety?
-
I have a loop set up calling mg_poll with a 0 ms timeout. All packet reads into here get put into a circular buffer than I then access from my other thread safely.
If a read takes say, 2 milliseconds, I believe this would delay the actual tcp packet sending from my mg_ws_write by 2 milliseconds due to packet writes waiting on the poll event to be processed. I saw another issue here about waking up the manager in order to perform an immediate write but the referenced wakeup function no longer seems to exist.
Is there a way to wake up the manager to immediately send a ws packet without waiting on the next poll?
Thanks!
HI, I'm trying to figure out if it's thread safe to call mg_ws_write from a completely different thread than the thread doing the reads.
I read through a bunch of issues/questions here and my guess so far is that this is fine. It seems that the websocket send events fire on the poll event. Presumably, as long as I'm mg_ws_write ing from the same thread, I don't think it could have any async issues.
However, then I saw this comment:
#139 (comment)
Would be any issues calling mg_ws_write without dealing with thread safety?
I have a loop set up calling mg_poll with a 0 ms timeout. All packet reads into here get put into a circular buffer than I then access from my other thread safely.
If a read takes say, 2 milliseconds, I believe this would delay the actual tcp packet sending from my mg_ws_write by 2 milliseconds due to packet writes waiting on the poll event to be processed. I saw another issue here about waking up the manager in order to perform an immediate write but the referenced wakeup function no longer seems to exist.
Is there a way to wake up the manager to immediately send a ws packet without waiting on the next poll?
Thanks!