Trash Talk - Threads! Cyan~Fire - Sat Sep 03, 2005 4:07 pm Post subject: Threads!
OK, way back when I was first experimenting with the idea of putting the recv() calls of MERVBot in separate threads, catid said I would have to make a mutex for each plugin. I'm not sure if this is the case.
Here's my basic layout: Class Host "owns" all the loaded plugins. Code in Host, and therefore code in each plugin, is entered in four possible ways: either by the periodic doEvents() function call, the disconnect() function call, the destructor at the end of main(), or by the callback from the receiver loop. doEvents(), disconnect(), and the callback use a mutex. By time the destructor is called, the receiver thread has died.
Does anybody see any possibility for an instance of the plugin to be entered by two threads at once?
Mr Ekted - Sat Sep 03, 2005 4:49 pm Post subject:
Why even bother with this crap? Just make the socket non-blocking and do it synchronously.
Cyan~Fire - Sun Sep 04, 2005 11:54 am Post subject:
Because WSAWaitForMultipleEvents() was using more time (with a 0ms delay) than any function other than main.
Mr Ekted - Sun Sep 04, 2005 3:37 pm Post subject:
I've never used that function before. I just do:
socket()
connect()
ioctlsocket()
send()
recv()
closesocket()
Cyan~Fire - Sun Sep 04, 2005 4:20 pm Post subject:
Yeah, I don't use it either (I try to stay away from MS extensions...) but catid was. I'm assuming you would just call recv() and then check for WSAEWOULDBLOCK?
Gravitron - Sun Sep 04, 2005 4:30 pm Post subject:
Cyan, just accept the fact that you're a moron and this is over your head and stop bothering people with your problems.
Actually, go learn java and form the dorkclub with cerium.
Cyan~Fire - Sun Sep 04, 2005 8:36 pm Post subject:
Thanks for gracing my thread with your presence.