From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: awaking a thread ... waiting on select or poll
Date: 13 Apr 2001 11:25:31 -0500 [thread overview]
Message-ID: <9b799r$6jm$1@charity.cs.utexas.edu> (raw)
In-Reply-To: qIsB6.3628$zv6.2622115@typhoon2.ba-dsg.net
In article <qIsB6.3628$zv6.2622115@typhoon2.ba-dsg.net>,
MrSignor <MrSignor@nospam_bellatlantic.net> wrote:
>Is there a reliable way (across Unix platforms) to wake-up a thread
>sleeping/waiting on a Select or Poll, that is not timing out the request.
>
>Basically, I have a thread, waiting for work on 1-n sockets. Upon
>occassion, I would like to wake the sleeping-thread, because I
>need to bring something to it's attention.
Um... Maybe I'm missing something obvious, but why not write to one of
the sockets it's listening to?
Perhaps you could use a pipe. When you want the thread to wake up and
do whatever, just write one byte to the pipe, using a non-blocking
write. If you succeed in writing, the poll()-ing/select()-ing process
will get the byte. If you don't succeed in writing, that means another
byte is already in the pipe waiting to be read, which is just as good
anyway, since the bytes are just random garbage designed to cause the
thread to wake up.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
next prev parent reply other threads:[~2001-04-13 16:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-13 1:34 awaking a thread ... waiting on select or poll MrSignor
2001-04-13 3:21 ` Richard D. Latham
2001-04-13 10:45 ` Dave Butenhof
2001-04-13 16:25 ` Logan Shaw [this message]
2001-05-29 17:29 ` anaonymous
2001-04-13 19:41 ` Norman Black
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox