summaryrefslogtreecommitdiff
path: root/glib/glibmm
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2021-05-23 14:58:47 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2021-05-23 14:58:47 +0200
commit85c707d3e77c993ec221f08adffdd0918b60fbc7 (patch)
tree6d7e159d0f8fdb7c2d011225b29ba6733153e036 /glib/glibmm
parent31b40adefc0d916246e60bd03a78b6ccae19f8a2 (diff)
downloadglibmm-85c707d3e77c993ec221f08adffdd0918b60fbc7.tar.gz
Glib::Timer: Add resume() and is_active()
Fixes #87
Diffstat (limited to 'glib/glibmm')
-rw-r--r--glib/glibmm/timer.cc12
-rw-r--r--glib/glibmm/timer.h18
2 files changed, 29 insertions, 1 deletions
diff --git a/glib/glibmm/timer.cc b/glib/glibmm/timer.cc
index 7f32b183..9e054f56 100644
--- a/glib/glibmm/timer.cc
+++ b/glib/glibmm/timer.cc
@@ -49,6 +49,12 @@ Timer::reset()
g_timer_reset(gobject_);
}
+void
+Timer::resume()
+{
+ g_timer_continue(gobject_);
+}
+
double
Timer::elapsed() const
{
@@ -61,6 +67,12 @@ Timer::elapsed(unsigned long& microseconds) const
return g_timer_elapsed(gobject_, &microseconds);
}
+bool
+Timer::is_active() const
+{
+ return g_timer_is_active(gobject_);
+}
+
void
usleep(unsigned long microseconds)
{
diff --git a/glib/glibmm/timer.h b/glib/glibmm/timer.h
index cbb5b444..d94d1362 100644
--- a/glib/glibmm/timer.h
+++ b/glib/glibmm/timer.h
@@ -29,7 +29,7 @@ namespace Glib
{
/** Portable stop watch interface.
- * This resembles a convient and portable timer with microseconds resolution.
+ * This resembles a convenient and portable timer with microseconds resolution.
*/
class GLIBMM_API Timer
{
@@ -48,6 +48,14 @@ public:
void stop();
void reset();
+ // Can't call it Timer::continue(). continue is a keyword in C and C++.
+ /** Resumes a timer that has previously been stopped with stop().
+ * stop() must be called before using this function.
+ *
+ * @newin{2,70]
+ */
+ void resume();
+
/** Get the elapsed time.
* @return The value in seconds.
*/
@@ -59,6 +67,13 @@ public:
*/
double elapsed(unsigned long& microseconds) const;
+ /** Exposes whether the timer is currently active.
+ *
+ * @newin{2,70]
+ * @return <tt>true</tt> if the timer is running, <tt>false</tt> otherwise.
+ */
+ bool is_active() const;
+
#ifndef DOXYGEN_SHOULD_SKIP_THIS
GTimer* gobj() { return gobject_; }
const GTimer* gobj() const { return gobject_; }
@@ -68,6 +83,7 @@ private:
GTimer* gobject_;
};
+/// Pauses the current thread for the given number of microseconds.
GLIBMM_API
void usleep(unsigned long microseconds);