[glibmm] Glib::Timer: Add resume() and is_active()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Glib::Timer: Add resume() and is_active()
- Date: Sun, 23 May 2021 13:07:10 +0000 (UTC)
commit 85c707d3e77c993ec221f08adffdd0918b60fbc7
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sun May 23 14:58:47 2021 +0200
Glib::Timer: Add resume() and is_active()
Fixes #87
glib/glibmm/timer.cc | 12 ++++++++++++
glib/glibmm/timer.h | 18 +++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
---
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_, µseconds);
}
+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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]