HTDJ Threads
From Hang The DJ
HTDJ THREADS
- HTDJ has the main MFC UI thread, and additional threads to talk to the STDJ server(s).
- The main thread contains a STDJInterface object.
- For every active server, one or more threads are available to talk to that server.
- Typically, there is one main server thread, plus additional threads for each file transer.
organization
------------
STDJInterface
server list
sendtoserver
stuffs TO into server's q/a cache
signals via event to send
server contains
server details
main thread
server q/a cache
pointer back to server object
pointer back to stjdinterface, for sending notifications
ping()
SendServerPing
SendToServer - WRONG
this should send directly, not via event
just lock and add to the cache, then call sendquestions()
sendquestions()
the http workhorse!
calls ReceiveFromServer() (ie receive())
receive()
extra threads created for file transfers
same exact format as main thread
just seperate http channel to optimize bandwidth
allows for a "calibrate to maximize bandwidth" function
more than one thread may be desired for one file transfer
STDJThread::Main() runs all day long waiting for signals m_pThis->m_pSTDJ->PingServers(); if no requests are made before timeout, just send pings m_pThis->m_pSTDJ->SendQuestions(); the only other event is NewQuestionEvent, send right away