libzypp: zyppng::EventLoop Class Reference

libzypp 17.38.11

zyppng::EventLoop Class Reference

`#include <zypp-core/ng/base/eventloop.h>`

Inheritance diagram for zyppng::EventLoop:

## Public Types
using | Ptr = EventLoopRef
using | WeakPtr = EventLoopWeakRef
Public Types inherited from zyppng::Base
using | Ptr = std::shared_ptr<Base>
using | WeakPtr = std::weak_ptr<Base>

## Public Member Functions
| ~EventLoop () override
void | run ()
void | quit ()
std::shared_ptr< EventDispatcher > | eventDispatcher () const
Public Member Functions inherited from zyppng::Base
| Base ()
virtual | ~Base ()
WeakPtr | parent () const
void | addChild (const Base::Ptr &child)
void | removeChild (const Ptr &child)
const std::unordered_set< Ptr > & | children () const
std::thread::id | threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > | findChildren () const
template<typename T>
std::shared_ptr< T > | shared_this () const
template<typename T>
std::shared_ptr< T > | shared_this ()
template<typename T>
std::weak_ptr< T > | weak_this () const
template<typename T>
std::weak_ptr< T > | weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
void | setData (uint32_t quark, zypp::AutoDispose< void * > data)
void * | data (uint32_t quark)
void | clearData (uint32_t quark)

## Static Public Member Functions
static Ptr | create (GMainContext *ctx=nullptr)
static Ptr | create (EventDispatcherRef dispatcher)
Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) | make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Private Member Functions
| EventLoop (GMainContext *ctx=nullptr)
| EventLoop (EventDispatcherRef dispatcher)

## Additional Inherited Members
Protected Member Functions inherited from zyppng::Base
| Base (BasePrivate &dd)
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivate > | d_ptr

## Detailed Description

The EventDispatcher class implements the libzypp event loop.

A event loop is used to execute multiple tasks concurrently. This is not implemented using threads but usually by either using Timers to poll a ressource or by reacting on events from a file descriptor or socket. In a application like zypper where we make use of I/O heavy tasks like downloading packages, rebuilding the repo metadata or generating a checksum over a file the application needs to wait more for those tasks to finish than actually doing anything. By using a event loop we can start one of those tasks and let the OS handle the execution and subscribe to certain events that can happen, utilizing more of the CPU compared to starting all the tasks serially.

Definition at line 42 of file eventloop.h.

## Member Typedef Documentation

## ◆ Ptr

using zyppng::EventLoop::Ptr = EventLoopRef

Definition at line 47 of file eventloop.h.

## ◆ WeakPtr

using zyppng::EventLoop::WeakPtr = EventLoopWeakRef

Definition at line 48 of file eventloop.h.

## Constructor & Destructor Documentation

## ◆ ~EventLoop()

zyppng::EventLoop::~EventLoop | ( |  | ) |
| override

Definition at line 24 of file eventloop_glib.cc.

## ◆ EventLoop() [1/2]

zyppng::EventLoop::EventLoop | ( | GMainContext * | ctx = nullptr | ) |
| private

Definition at line 20 of file eventloop_glib.cc.

## ◆ EventLoop() [2/2]

zyppng::EventLoop::EventLoop | ( | EventDispatcherRef | dispatcher | ) |
| private

Definition at line 11 of file eventloop_glib.cc.

## Member Function Documentation

## ◆ create() [1/2]

EventLoop::Ptr zyppng::EventLoop::create | ( | GMainContext * | ctx = nullptr | ) |
| static

Definition at line 29 of file eventloop_glib.cc.

## ◆ create() [2/2]

EventLoop::Ptr zyppng::EventLoop::create | ( | EventDispatcherRef | dispatcher | ) |
| static

Definition at line 34 of file eventloop_glib.cc.

## ◆ run()

void zyppng::EventLoop::run | ( |  | ) |

Start dispatching events, this function will block until

See also
  quit was called for the EventLoop instance

Definition at line 40 of file eventloop_glib.cc.

## ◆ quit()

void zyppng::EventLoop::quit | ( |  | ) |

Stop dispatching events and return control from the run function

Definition at line 51 of file eventloop_glib.cc.

## ◆ eventDispatcher()

std::shared_ptr< EventDispatcher > zyppng::EventLoop::eventDispatcher | ( |  | ) | const

Returns the event dispatcher used by the MainLoop instance

Definition at line 56 of file eventloop_glib.cc.

The documentation for this class was generated from the following files:

- zypp-core/ng/base/eventloop.h
- zypp-core/ng/base/eventloop_glib.cc