libzypp: zypp-core/ng/base/timer.h Source File

libzypp 17.38.14

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
17#include <zypp-core/ng/base/zyppglobal.h>
18#include <zypp-core/ng/base/Base>
19#include <zypp-core/ng/base/Signals>
20#include <functional>
21
22namespace zyppng {
23
24class TimerPrivate;
25class EventDispatcher;
26 ZYPP_FWD_DECL_TYPE_WITH_REFS (Timer);
27
44 class Timer : public Base
45{
46 ZYPP_DECLARE_PRIVATE(Timer)
47 friend class EventDispatcher;
48
49public:
50
51 using Ptr = std::shared_ptr<Timer>;
52 using WeakPtr = std::shared_ptr<Timer>;
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
shared_ptr
zyppng::Base::Base
Base()
Definition base.cc:20
zyppng::EventDispatcher
Definition eventdispatcher.h:43
zyppng::SignalProxy
Definition signals.h:325
zyppng::TimerPrivate
Definition timer.cc:16
zyppng::Timer
The Timer class provides repetitive and single-shot timers.
Definition timer.h:45
zyppng::Timer::expires
uint64_t expires() const
Definition timer.cc:115
zyppng::Timer::Timer
Timer()
Definition timer.cc:189
zyppng::Timer::singleShot
bool singleShot() const
Definition timer.cc:65
zyppng::Timer::elapsedSince
static uint64_t elapsedSince(const uint64_t start)
Definition timer.cc:83
zyppng::Timer::start
void start()
Definition timer.cc:149
zyppng::Timer::now
static uint64_t now()
Definition timer.cc:70
zyppng::Timer::elapsed
uint64_t elapsed() const
Definition timer.cc:109
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:52
zyppng::Timer::isRunning
bool isRunning() const
Definition timer.cc:144
zyppng::Timer::sigExpired
SignalProxy< void(Timer &t)> sigExpired()
This signal is always emitted when the timer expires.
Definition timer.cc:120
zyppng::Timer::Ptr
std::shared_ptr< Timer > Ptr
Definition timer.h:51
zyppng::Timer::started
uint64_t started() const
Definition timer.cc:89
zyppng::Timer::WeakPtr
std::shared_ptr< Timer > WeakPtr
Definition timer.h:52
zyppng::Timer::EventDispatcher
friend class EventDispatcher
Definition timer.h:47
zyppng::Timer::setSingleShot
void setSingleShot(bool singleShot=true)
Sets the timer to trigger only once, after it has expired once.
Definition timer.cc:60
zyppng::Timer::remaining
uint64_t remaining() const
Definition timer.cc:99
zyppng::Timer::interval
uint64_t interval() const
Definition timer.cc:94
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:125
zyppng::Timer::stop
void stop()
Stops the timer if it is running. The.
Definition timer.cc:173
std
Definition ansi.h:855
zyppng
Definition MediaNetworkRequestExecutor.h:16
zyppglobal.h
ZYPP_DECLARE_PRIVATE
#define ZYPP_DECLARE_PRIVATE(Class)
Definition zyppglobal.h:80
ZYPP_FWD_DECL_TYPE_WITH_REFS
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:119