Interrupting sleep call
Interrupting sleep call
- Subject: Interrupting sleep call
- From: Tim McLaren <email@hidden>
- Date: Thu, 6 Dec 2001 19:46:02 +1100
I wonder if anyone can help me with a problem I am having. I am
writing some code which is multi-threaded which one of the threads
performs a sleep within a loop while waiting for some data from the
other thread to process. The idea of using the sleep is to stop it
from free wheeling and using unnecessary cpu cycles.
What I am trying to do is to be able to wake up the sleeping thread
before the sleep has completed by sending a signal to the program
from another thread.
According to the man page for sleep this should work which it did
when I wrote a simple c program to test it. Unfortunately, when
called from a cocoa app the sleep does not exit prematurely, even
though the signal is caught by the signal handler.
Does anybody know of a way to make this work within a cocoa app.
Thanks
Tim.
--