30 std::weak_ptr<EventDispatcher>
_ev;
54 return std::shared_ptr<Timer>(
new Timer() );
67 return d_func()->_singleShot;
76 WAR <<
"Unable to get current monotonic time, timers will not work" << std::endl;
79 return ( uint(
now.tv_sec) * 1000 ) + uint(
now.tv_nsec * 1
e-6 );
96 return d_func()->_requestedTimeout;
104 if ( elapsed >=
d->_requestedTimeout )
106 return (
d->_requestedTimeout -
elapsed );
117 return d_func()->_beginMs +
d_func()->_requestedTimeout;
122 return d_func()->_expired;
135 if (
d->_singleShot )
139 d->_expired.emit( *
this );
146 return d_func()->_isRunning;
158 d->_requestedTimeout = timeout;
161 if ( !
d->_isRunning ) {
162 auto ev =
d->_ev.lock();
166 ev->registerTimer( *
this );
168 d->_isRunning =
true;
177 if ( !
d->_isRunning )
180 auto ev =
d->_ev.lock();
184 ev->removeTimer( *
this );
186 d->_isRunning =
false;
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Base class for Exception.
static std::shared_ptr< EventDispatcher > instance()
TimerPrivate & operator=(const TimerPrivate &)=delete
TimerPrivate(const TimerPrivate &)=delete
uint64_t _requestedTimeout
Signal< void(Timer &t) _expired)
std::weak_ptr< EventDispatcher > _ev
TimerPrivate(TimerPrivate &&)=delete
TimerPrivate & operator=(TimerPrivate &&)=delete
The Timer class provides repetitive and single-shot timers.
static uint64_t elapsedSince(const uint64_t start)
static std::shared_ptr< Timer > create()
Creates a new Timer object, the timer is not started at this point.
void setSingleShot(bool singleShot=true)
Sets the timer to trigger only once, after it has expired once.
uint64_t remaining() const
uint64_t interval() const
SignalProxy< void(Timer &t) sigExpired)()
This signal is always emitted when the timer expires.
uint64_t expire()
Advances the internal clock of the timer, if the timer expires the sigExpired signal is emitted.
void stop()
Stops the timer if it is running. The.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define ZYPP_IMPL_PRIVATE(Class)
#define ZYPP_DECLARE_PUBLIC(Class)