>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.
On Monday 06 June 2005 14:10, Johan Kohler wrote:
> 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)?
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.