libzypp  17.32.5
eventloop_glib.cc
Go to the documentation of this file.
2 #include <zypp-core/zyppng/base/EventDispatcher>
3 
4 namespace zyppng {
5 
7  { }
8 
10 
12  : Base ( * new EventLoopPrivate(*this) )
13  {
14  Z_D();
15  d->_dispatcher = ThreadData::current().ensureDispatcher();
16  d->_loop = g_main_loop_new( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()), false );
17  }
18 
20  {
21  g_main_loop_unref( d_func()->_loop );
22  }
23 
25  {
26  return Ptr( new EventLoop() );
27  }
28 
30  {
31  Z_D();
32  g_main_context_push_thread_default( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()) );
33  g_main_loop_run( d->_loop );
34  d->_dispatcher->clearUnrefLaterList();
35  g_main_context_pop_thread_default( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()) );
36  }
37 
39  {
40  g_main_loop_quit( d_func()->_loop );
41  }
42 
43  std::shared_ptr<EventDispatcher> EventLoop::eventDispatcher() const
44  {
45  return d_func()->_dispatcher;
46  }
47 }
std::shared_ptr< EventDispatcher > eventDispatcher() const
~EventLoop() override
EventLoopRef Ptr
Definition: eventloop.h:47
#define Z_D()
Definition: zyppglobal.h:104
static Ptr create()
static ThreadData & current()
Definition: threaddata.cc:16
std::shared_ptr< EventDispatcher > ensureDispatcher()
Definition: threaddata.cc:32
ZYPP_IMPL_PRIVATE(UnixSignalSource)
EventLoopPrivate(EventLoop &p)