Re: Using too many threads?
- From: Marty <net@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 06 Jul 2009 13:22:26 -0700
Alex Taylor wrote:
On Sat, 4 Jul 2009 16:11:15 UTC, Steven Levine <steve53@xxxxxxxxxxxxxxxxxxx>
wrote:
I would have to guess you are using non-blocking sockets. If you have a
socket per thread there's no reason not to block. The only downside to
blocking sockets is that it takes a bit more work to ensure an app will
always shut down quickly and cleanly, when requested.
Correct. I originally planned to use blocking sockets, but quickly
discovered that wasn't going to work.
The Ui thread has to be able to send messages to the thread that talks on
the socket, so commands can be sent to the client at the other end on
demand.
If we subscribe to the 1/10th second rule for GUI response (or even
bring it up to date and make it the 1/1000th of a second), you should
still be able to do the socket send from your GUI thread. If this is
too ugly for you, then create a new thread which listens to a queue.
Have the GUI post its "sent" messages to the queue and the unique thread
will service them on demand.
OS/2's implementation of threads is one of the best in existence! Don't
be afraid to make excessive use of them when it helps your design and
app behavior.
I also need to take certain actions at specific intervals (for instance,
send a refresh command to the remote client every 5 seconds), and if the
loop only iterates every time data comes in, that timing gets thrown out
the window.
Make a new thread that does a DosSleep(5) and then sends the refresh.
If for some bizarre reason, you have to serialize your network IO
operations, use a mutex semaphore.
--
Reverse the parts of the e-mail address to reply by mail.
.
- References:
- Using too many threads?
- From: Alex Taylor
- Re: Using too many threads?
- From: Steven Levine
- Re: Using too many threads?
- From: Alex Taylor
- Using too many threads?
- Prev by Date: Re: Using too many threads?
- Next by Date: Re: Using too many threads?
- Previous by thread: Re: Using too many threads?
- Next by thread: Exporting symbols from EXE to DLL?
- Index(es):
Relevant Pages
|
Loading