libzypp  17.22.0
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/zyppng/base/Base>
19 #include <zypp/zyppng/base/Signals>
20 #include <functional>
21 
22 namespace zyppng {
23 class TimerPrivate;
24 class EventDispatcher;
25 
42 class Timer : public Base
43 {
45  friend class EventDispatcher;
46 
47 public:
48 
49  using Ptr = std::shared_ptr<Timer>;
50  using WeakPtr = std::shared_ptr<Timer>;
51 
55  static std::shared_ptr<Timer> create ();
56  virtual ~Timer ();
57 
62  void setSingleShot ( bool singleShot = true );
63 
67  bool singleShot () const;
68 
72  static uint64_t now ();
73 
77  uint64_t started () const;
78 
82  uint64_t interval () const;
83 
87  uint64_t remaining () const;
88 
92  uint64_t elapsed () const;
93 
97  uint64_t expires () const;
98 
105  uint64_t expire ();
106 
110  bool isRunning ( ) const;
111 
115  void start ( );
116 
121  void start ( uint64_t timeout );
122 
126  void stop ();
127 
131  SignalProxy<void (Timer &t)> sigExpired ();
132 
133 protected:
134  Timer ();
135 };
136 
137 }
138 
139 #endif
zyppng::EventDispatcher
Definition: eventdispatcher.h:49
zyppng::Timer::isRunning
bool isRunning() const
Definition: timer.cc:133
zyppng::Timer::start
void start()
Definition: timer.cc:138
zyppng::Timer::started
uint64_t started() const
Definition: timer.cc:77
zyppng::Timer::elapsed
uint64_t elapsed() const
Definition: timer.cc:97
zyppng::Base
Definition: base.h:32
zyppng::Timer::create
static std::shared_ptr< Timer > create()
Creates a new Timer object, the timer is not started at this point.
Definition: timer.cc:46
zyppng::Timer::remaining
uint64_t remaining() const
Definition: timer.cc:87
zyppng::Timer::setSingleShot
void setSingleShot(bool singleShot=true)
Sets the timer to trigger only once, after it has expired once.
Definition: timer.cc:54
zyppng::Timer::sigExpired
SignalProxy< void(Timer &t)> sigExpired()
This signal is always emitted when the timer expires.
Definition: timer.cc:109
zyppng::SignalProxy
Definition: signals.h:28
zyppng::Timer::singleShot
bool singleShot() const
Definition: timer.cc:59
zyppng::Timer::interval
uint64_t interval() const
Definition: timer.cc:82
zyppng::Timer::stop
void stop()
Stops the timer if its running. The.
Definition: timer.cc:162
zyppng::Timer
The Timer class provides repetitive and single-shot timers.
Definition: timer.h:42
zyppng::Timer::expires
uint64_t expires() const
Definition: timer.cc:104
zyppng::Timer::expire
uint64_t expire()
Advances the internal clock of the timer, if the timer expires the sigExpired signal is emitted.
Definition: timer.cc:114
zyppglobal.h
zyppng::Base::Ptr
std::shared_ptr< Base > Ptr
Definition: base.h:38
std
Definition: Arch.h:347
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition: zyppglobal.h:21
zyppng::Base::WeakPtr
std::weak_ptr< Base > WeakPtr
Definition: base.h:39
timeout
time_t timeout
Definition: MediaCurl.cc:66
zyppng
Definition: abstracteventsource.cc:8
zyppng::Timer::now
static uint64_t now()
Definition: timer.cc:64