100 ms delay function needed

Omer Musaev omerm at mercury.co.il
Wed Aug 29 11:05:55 BST 2001



> -----Original Message-----
> From: Rolf Magnus [mailto:ramagnus at zvw.de]
> Sent: Tuesday, August 28, 2001 5:49 PM
> To: kdevelop at kdevelop.org
> Subject: Re: 100 ms delay function needed
> 
> 
> On Tuesday, 28. August 2001 23:09, you wrote:
> 
> > Thanks for the replies.
> >
> > usleep() was what I was looking for but is not listed in 
> the C++ reference
> > or my favorite C++ book.
> >
> > I know that QT has a usleep function but my application is 
> for console use
> > only.
> 
> usleep is also available as a libc function. Do a "man 3 
> usleep"; you can 
> also use the POSIX nanosleep function.

the problem is that usleep sends a signal to your process. 
One way to implement usleep without use of signals is:

void safe_usleep( long usecs ) {
   struct timeval tout ;
   
   tout.tv_sec   = 0 ;
   tout.tv_usec  = usecs ;

   if ( select( 0, NULL, NULL, NULL, &tout ) != 0 ) {
       // select failed - throw an exception here, if you want
       // 
       ;
    }
 }


> 
> 
> -- 
> Why do scientists call it _re_search when looking for something new?
> 
> -
> to unsubscribe from this list send an email to 
> kdevelop-request at kdevelop.org with the following body:
> unsubscribe »your-email-address«
> 

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list