[ENet-discuss] Multithreading: dealing with enet_host_service blocking
Beau Albiston
BAlbiston at totimm.com
Mon Sep 13 14:12:37 PDT 2010
Hello All,
I'm particularly interested in how people are dealing with the enet_host_service blocking on receive when you have things to send...
I have solved this problem already, but was curious as to how others have solved the same problem. My solution involved making (only for Win32 in my case) modifications to the enet_socket_wait function to allow waiting on socket send and receive, as well as a "cancel wait" event object (using WSAEventSelect, and WSAWaitForMultipleObjects). I then added an additional function (enet_socket_cancel_wait) that signals the "cancel wait" event object and wakes the network thread. From there, the enet_host_service function returns with a timeout event from which I can then pluck a queued send command from my queue (using lock-free queues). So, my main thread queues a send command and then calls enet_socket_cancel_wait to wake the network thread (in case it is waiting on recv) to process the send command.
(Lee, if you're interested in the changes, I can send them to you.)
Thanks,
-Beau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20100913/97591102/attachment.html>
More information about the ENet-discuss
mailing list