Delay or Sleep

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Delay or Sleep

Johan Kohler
Hi,
I want to implement a delay or a certain number of ms.  Under Windows, I  
would use Sleep().  Is there an equivalent GTKmm/glib Way(TM)?

Thanks
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--------------------------------------------------------------------
Please find our disclaimer at http://www.ukzn.ac.za/disclaimer
--------------------------------------------------------------------
<<<<gwavasig>>>>
_______________________________________________
gtkmm-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Delay or Sleep

Paul Davis
>Hi,
>I want to implement a delay or a certain number of ms.  Under Windows, I  
>would use Sleep().  Is there an equivalent GTKmm/glib Way(TM)?

first, let me point out that gtkmm/glib are not equivalents to the
win32 API. gtkmm is a thin wrapper around a GUI toolkit (gtk), and gtk
does not concern itself with issues other than being a GUI
toolkit. glib is a portability and convenience library, that
encapsulates many common programming tasks done in C so that the
resulting code is either more portable between operating systems or
neater, or both.

on any POSIX system, sleep(2), usleep (2) and nanonsleep (2) are the
primary system calls for putting a thread/task to sleep for a
specified time period. however, the resolution of these functions is
entirely dependendent on the internal implementation of the operating
system and may differ from the publicized resolution that the
functions claim. it can also be affected by priviledges owned by the
thread. for example, on older versions of Linux, it was impossible to
sleep for less than 10ms, unless you were a realtime thread and then
waits of 2ms or less would busy wait in the kernel. Ick.

it is very unusual to need to do this in a GUI program, so why don't
you explain a little bit more about what you are trying to do.

--p
_______________________________________________
gtkmm-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Delay or Sleep

Chris Vine
In reply to this post by Johan Kohler
On Monday 06 June 2005 14:10, Johan Kohler wrote:
> Hi,
> I want to implement a delay or a certain number of ms.  Under Windows, I
> would use Sleep().  Is there an equivalent GTKmm/glib Way(TM)?
>
> Thanks

Glib::usleep() will sleep the specified number of microseconds by yielding to
other processes or threads (it is not a busy wait), except that in practice
its minimum resolution is dependent on the kernel tick rate which in the 2.6
Linux kernel is 1ms by default, and also on whatever other loading is on the
system at the time.  In other words, it is not a hard realtime sleep but is a
minimum wait time.

Chris

--
Summer is y-cumen in, lhude sing, cuccu!
Groweth sed and bloweth med, springeth the wude nu.
_______________________________________________
gtkmm-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtkmm-list