On Tuesday 22 June 2004 14:22, Vinu V wrote: > Hi, > > My requirement is to have a timer implementation using Pth library. > > The call shown below causes the callback "func" to be called at the > specified timeout: > --------------------------------------------------------------------------- >-- ----------------------------------------------- > main_func() > { > pth_ev = pth_event(PTH_EVENT_FUNC, func, NULL, pth_timeout(0, > 500000)); > pth_wait(pth_ev); /* Thread waits here . it is signalled from > callback - func*/ > } > > However, the execution of the main_func thread is blocked until it is > signalled which happens when the callback is called. > > int func(void * arg) > { > /* In timer callback */ > } > > I need to have a timer implementation similar to timer_init, timer_add, > timer_settime etc....where the caller does not get blocked. > Is there a way of doing the same using Pth.? > > Kind Regards, > Bhanu Kurpad
If I was you I'd spawn a special "timer thread". This thread would sleep for a while and when it wakes up it would call the callback function and exit or sleep again, depending on what kind of behaviour is needed. Regards Marc ______________________________________________________________________ GNU Portable Threads (Pth) http://www.gnu.org/software/pth/ Development Site http://www.ossp.org/pkg/lib/pth/ Distribution Files ftp://ftp.gnu.org/gnu/pth/ Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/ User Support Mailing List [EMAIL PROTECTED] Automated List Manager (Majordomo) [EMAIL PROTECTED]