libzypp 17.38.7
eventloop_glib.cc
Go to the documentation of this file.
2#include <zypp-core/ng/base/EventDispatcher>
3
4namespace zyppng {
5
8
10
11 EventLoop::EventLoop( EventDispatcherRef disp )
12 : Base ( * new EventLoopPrivate(*this) )
13 {
14 Z_D();
15 d->_dispatcher = std::move(disp);
16 d->_loop = g_main_loop_new( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()), false );
17 }
18
19
21 : EventLoop( ThreadData::current().ensureDispatcher( ctx ) )
22 {}
23
25 {
26 g_main_loop_unref( d_func()->_loop );
27 }
28
30 {
31 return Ptr( new EventLoop( ctx ) );
32 }
33
34 EventLoop::Ptr EventLoop::create( EventDispatcherRef dispatcher )
35 {
36 return Ptr( new EventLoop( std::move(dispatcher) ) );
37 }
38
39
41 {
42 Z_D();
43 g_main_context_push_thread_default( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()) );
45 d->_dispatcher->clearUnrefLaterList();
46 g_main_context_pop_thread_default( reinterpret_cast<GMainContext*>(d->_dispatcher->nativeDispatcherHandle()) );
47 };
48 g_main_loop_run( d->_loop );
49 }
50
52 {
53 g_main_loop_quit( d_func()->_loop );
54 }
55
56 std::shared_ptr<EventDispatcher> EventLoop::eventDispatcher() const
57 {
58 return d_func()->_dispatcher;
59 }
60}
#define zypp_defer
BasePrivate(Base &b)
Definition base_p.h:17
EventLoopPrivate(EventLoop &p)
EventLoopRef Ptr
Definition eventloop.h:47
EventLoop(GMainContext *ctx=nullptr)
static Ptr create(GMainContext *ctx=nullptr)
std::shared_ptr< EventDispatcher > eventDispatcher() const
struct _GMainContext GMainContext
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:85
#define Z_D()
Definition zyppglobal.h:98