Le 10/10/2013 12:57, Angus Robertson - Magenta Systems Ltd a écrit :
So my question: is there any way to attach a client connection to
another thread immediately, from the main thread?
Probably, but I've said I've not done it myself, no need.  Others may have done
so, but I don't believe it necessary for your application.

The problem is really that my worker threads are not available at
the time the client socket needs to be attached to one of those,
and waiting for a worker thread to be available would block the
main thread.
That is what Windows messages and events are for.


Thank you, this put me on the right track. I have reworked the server to not use job queues at all, but rely exclusively on message queues:
- each worker thread maintains a list of attached client connections
- the main thread selects the most appropriate thread and request the worker thread to attach the client connection - each thread implements a custom message pump that browse each client connection that required to be attached, attach them, then browse their respective message queue - when the message queue of a client connection is terminated (WM_QUIT received from main thread OnClientDisconnect), the client is removed from the list of attached clients

This seems to work ok

I'm still fighting with the root cause of my question (AV on server socket), but will start a new discussion for that
Thanks,


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to