libzypp 17.37.17
timer.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPP_NG_BASE_TIMER_H_INCLUDED
15#define ZYPP_NG_BASE_TIMER_H_INCLUDED
16
18#include <zypp-core/zyppng/base/Base>
19#include <zypp-core/zyppng/base/Signals>
20#include <functional>
21
22namespace zyppng {
23
24class TimerPrivate;
25class EventDispatcher;
27
44class Timer : public Base
45{
47 friend class EventDispatcher;
48
49public:
50
53
57 static std::shared_ptr<Timer> create ();
58 ~Timer () override;
59
64 void setSingleShot ( bool singleShot = true );
65
69 bool singleShot () const;
70
74 static uint64_t now ();
75
79 static uint64_t elapsedSince ( const uint64_t start );
80
84 uint64_t started () const;
85
89 uint64_t interval () const;
90
94 uint64_t remaining () const;
95
99 uint64_t elapsed () const;
100
104 uint64_t expires () const;
105
112 uint64_t expire ();
113
117 bool isRunning ( ) const;
118
122 void start ( );
123
128 void start ( uint64_t timeout );
129
133 void stop ();
134
138 SignalProxy<void (Timer &t)> sigExpired ();
139
140protected:
141 Timer ();
142};
143
144}
145
146#endif
The Timer class provides repetitive and single-shot timers.
Definition timer.h:45
uint64_t expires() const
Definition timer.cc:115
bool singleShot() const
Definition timer.cc:65
static uint64_t elapsedSince(const uint64_t start)
Definition timer.cc:83
void start()
Definition timer.cc:149
static uint64_t now()
Definition timer.cc:70
uint64_t elapsed() const
Definition timer.cc:109
static std::shared_ptr< Timer > create()
Creates a new Timer object, the timer is not started at this point.
Definition timer.cc:52
bool isRunning() const
Definition timer.cc:144
SignalProxy< void(Timer &t)> sigExpired()
This signal is always emitted when the timer expires.
Definition timer.cc:120
std::shared_ptr< Timer > Ptr
Definition timer.h:51
uint64_t started() const
Definition timer.cc:89
std::shared_ptr< Timer > WeakPtr
Definition timer.h:52
friend class EventDispatcher
Definition timer.h:47
void setSingleShot(bool singleShot=true)
Sets the timer to trigger only once, after it has expired once.
Definition timer.cc:60
uint64_t remaining() const
Definition timer.cc:99
uint64_t interval() const
Definition timer.cc:94
uint64_t expire()
Advances the internal clock of the timer, if the timer expires the sigExpired signal is emitted.
Definition timer.cc:125
void stop()
Stops the timer if it is running. The.
Definition timer.cc:173
Definition Arch.h:364
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:87
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126