From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,3b3321b91f88c41e X-Google-Attributes: gid109fba,public X-Google-Thread: f678f,3b3321b91f88c41e X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1994-05-19 17:30:55 PST Newsgroups: comp.lang.c++,comp.unix.osf.misc Path: bga.com!news.sprintlink.net!hookup!news.kei.com!yeshua.marcam.com!zip.eecs.umich.edu!newsxfer.itd.umich.edu!gatech!swrinde!news.uh.edu!uuneo.neosoft.com!jabberwock!daniels From: daniels@biles.com (Brad Daniels) Subject: Re: Race condition during object destruction. How to avoid? References: Organization: Biles and Associates Date: Thu, 19 May 1994 20:48:59 GMT Message-ID: Xref: bga.com comp.lang.c++:16063 comp.unix.osf.misc:551 In article , Christopher Barber wrote: >>>>>> "BD" == Brad Daniels writes: > > BD> I have a class which models pthread condition variables. I'd like > BD> to make a subclass of that class which will wake up at fixed > BD> intervals regardless of other conditions. To achieve this, I tried > BD> making a class with an associated thread which periodically signals > BD> the condition variable to wake up (after forcing the predicate to > BD> be true).... > >Why not save yourself a lot of trouble and implement the wait() call on the >subclass using pthread_cond_timedwait()? That is actually the work-around I put in, though I have to use pthread_getexpiration_np in order to figure out the end time, and I hate using _np routines. Another part of the problem with this approach is that the timing is less reliable. I have to determine the time for the next read before commencing the read, so that my interval isn't (time for read to complete) + interval instead of just the given interval. Also, if a network event causes a read to take longer than the interval, I will get two reads, one immediately after the other, with the next read thereafter commencing at a new offset (e.g. I might get reads starting at 10 sec, 20 sec, 30 sec, 42 sec, 52 sec, etc.) For my current purposes, this shouldn't be a problem, but I'd like to code something more reliable if possible. - Brad ------------------------------------------------------------ + Brad Daniels | Was mich nicht umbringt + + Biles and Associates | macht mich hungrig. + + These are my views, not B&A's | + ------------------------------------------------------------