libzypp: zypp-core/zyppng/base/eventloop_glib.cc Source File

libzypp 17.36.6

eventloop_glib.cc
Go to the documentation of this file.
1#include "private/eventloop_glib_p.h"
2#include <zypp-core/zyppng/base/EventDispatcher>
3
4namespace zyppng {
5
6 EventLoopPrivate::EventLoopPrivate( EventLoop &p ) : BasePrivate( p )
7 { }
8
9 ZYPP_IMPL_PRIVATE(EventLoop)
10
11 EventLoop::EventLoop()
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
19 EventLoop::~EventLoop()
20 {
21 g_main_loop_unref( d_func()->_loop );
22 }
23
24 EventLoop::Ptr EventLoop::create()
25 {
26 return Ptr( new EventLoop() );
27 }
28
29 void EventLoop::run()
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
38 void EventLoop::quit()
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}
zyppng::BasePrivate::BasePrivate
BasePrivate(Base &b)
Definition base_p.h:17
zyppng::Base::Base
Base()
Definition base.cc:20
zyppng::EventLoopPrivate
Definition eventloop_glib_p.h:12
zyppng::EventLoopPrivate::EventLoopPrivate
EventLoopPrivate(EventLoop &p)
Definition eventloop_glib.cc:6
zyppng::EventLoop
Definition eventloop.h:43
zyppng::EventLoop::EventLoop
EventLoop()
Definition eventloop_glib.cc:11
zyppng::EventLoop::run
void run()
Definition eventloop_glib.cc:29
zyppng::EventLoop::Ptr
EventLoopRef Ptr
Definition eventloop.h:47
zyppng::EventLoop::create
static Ptr create()
Definition eventloop_glib.cc:24
zyppng::EventLoop::quit
void quit()
Definition eventloop_glib.cc:38
zyppng::EventLoop::~EventLoop
~EventLoop() override
Definition eventloop_glib.cc:19
zyppng::EventLoop::eventDispatcher
std::shared_ptr< EventDispatcher > eventDispatcher() const
Definition eventloop_glib.cc:43
eventloop_glib_p.h
zyppng
Definition MediaCurl2.h:22
zyppng::ThreadData::current
static ZYPP_API ThreadData & current()
Definition threaddata.cc:16
zyppng::ThreadData::ensureDispatcher
std::shared_ptr< EventDispatcher > ensureDispatcher()
Definition threaddata.cc:32
ZYPP_IMPL_PRIVATE
#define ZYPP_IMPL_PRIVATE(Class)
Definition zyppglobal.h:92
Z_D
#define Z_D()
Definition zyppglobal.h:105