libzypp 17.37.17
abstracteventsource.cc
Go to the documentation of this file.
3#include "eventdispatcher.h"
4#include "private/base_p.h"
5
7
8namespace zyppng {
9
11{
12 auto ev = EventDispatcher::instance();
13 if ( !ev )
14 ZYPP_THROW( zypp::Exception( "Creating event sources without a EventDispatcher instance is not supported" ) );
15 _ev = ev;
16}
17
19
23
27
29{
30 Z_D();
31 auto ev = d->_ev.lock();
32 //if ev is null , eventloop is shutting down
33 if ( ev )
34 ev->removeEventSource( *this );
35}
36
37std::weak_ptr<EventDispatcher> AbstractEventSource::eventDispatcher() const
38{
39 return d_func()->_ev;
40}
41
43{
44 auto ev = d_func()->_ev.lock();
45
46 //if ev is null we are shutting down
47 if ( !ev )
48 return;
49 ev->updateEventSource( *this, fd, mode );
50}
51
53{
54 auto ev = d_func()->_ev.lock();
55
56 //if ev is null we are shutting down
57 if ( !ev )
58 return;
59 ev->removeEventSource( *this , fd );
60}
61
62}
Base class for Exception.
Definition Exception.h:153
std::weak_ptr< EventDispatcher > _ev
AbstractEventSourcePrivate(AbstractEventSource &p)
std::weak_ptr< EventDispatcher > eventDispatcher() const
void updateFdWatch(int fd, int mode)
BasePrivate(Base &b)
Definition base_p.h:17
static std::shared_ptr< EventDispatcher > instance()
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:92
#define Z_D()
Definition zyppglobal.h:105