libzypp 17.37.17
eventloop_glib.cc
Go to the documentation of this file.
2#include <zypp-core/zyppng/base/EventDispatcher>
3
4namespace zyppng {
5
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}
BasePrivate(Base &b)
Definition base_p.h:17
EventLoopPrivate(EventLoop &p)
EventLoopRef Ptr
Definition eventloop.h:47
static Ptr create()
std::shared_ptr< EventDispatcher > eventDispatcher() const
static ZYPP_API ThreadData & current()
Definition threaddata.cc:16
std::shared_ptr< EventDispatcher > ensureDispatcher()
Definition threaddata.cc:32
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:92
#define Z_D()
Definition zyppglobal.h:105