Re: Threads vs Select (was Re: Re(2): [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send))
Re: Threads vs Select (was Re: Re(2): [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send))
- Subject: Re: Threads vs Select (was Re: Re(2): [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send))
- From: email@hidden
- Date: Mon, 4 Feb 2002 14:42:11 -0500
On Monday, February 4, 2002, at 11:19 AM, Duane Murphy wrote:
How do you break a thread that is waiting on a read? Or rather what
happens when a thread is killed waiting on a read? Or how do you kill a
thread waiting on read?
If you have a thread waiting on a read and the program wants it to stop
in order to quit or because the user cancelled the request, what is the
right way of doing that?
Seems like just killing the thread doesnt properly unwind the stack so
some things might be left un-clean.
What is the right technique for this?
Have the read timeout at regular intervals, and have your read thread
check a suicide flag to see if it should kill itself. You still have to
use select
for this.
If you would rather have a callback implementation, then have only one
I/O thread
that implements a select loop, and use it to dispatch the callbacks to
your
I/O handlers.
If you are doing OOP, the Reactor pattern is a good model
for this.
email@hidden