libzypp 17.37.17
eventdispatcher_glib_p.h
Go to the documentation of this file.
1#ifndef ZYPP_BASE_EVENTDISPATCHER_GLIB_P_DEFINED
2#define ZYPP_BASE_EVENTDISPATCHER_GLIB_P_DEFINED
3
4#include "base_p.h"
6#include <glib.h>
7#include <thread>
8#include <unordered_map>
9#include <queue>
10
11namespace zyppng {
12
14
16{
17 GIOCondition reqEvents;
18 int pollfd = -1;
19 gpointer tag = nullptr;
20};
21
29{
30 GSource source;
33 std::vector<GUnixPollFD> pollfds;
34
35 static gboolean prepare(GSource *, gint *timeout);
36 static gboolean check(GSource *source);
37 static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
38
40 static void destruct ( GAbstractEventSource *src );
41};
42
50{
51 GSource source;
52 Timer *_t = nullptr;
53
54 static gboolean prepare(GSource *src, gint *timeout);
55 static gboolean check(GSource *source);
56 static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
57
58 static GLibTimerSource *create ();
59 static void destruct ( GLibTimerSource *src );
60};
61
63{
64 GlibWaitPIDData( GPid pid );
65 GlibWaitPIDData( GlibWaitPIDData &&other ) noexcept;
67
68 GlibWaitPIDData & operator= ( GlibWaitPIDData &&other ) noexcept;
69
70 guint tag = 0;
71 GSource *source = nullptr;
73};
74
76{
78public:
79 EventDispatcherPrivate( GMainContext *ctx, EventDispatcher &p );
80 ~EventDispatcherPrivate() override;
81
82 bool runIdleTasks();
83 void enableIdleSource ();
84
85 static std::shared_ptr<EventDispatcher> create ( );
86 static void waitPidCallback ( GPid pid, gint status, gpointer user_data );
87
88 std::thread::id _myThreadId;
89 GMainContext *_ctx = nullptr;
90
91 GSource *_idleSource = nullptr;
92
93 std::vector<GLibTimerSource *> _runningTimers;
94 std::vector<GAbstractEventSource *> _eventSources;
95 std::vector< std::shared_ptr<void> > _unrefLater;
96 std::queue< EventDispatcher::IdleFunction > _idleFuncs;
97 std::unordered_map<int, GlibWaitPIDData> _waitPIDs;
98 UnixSignalSourceWeakRef _signalSource;
99};
100
101}
102
103
104#endif
BasePrivate(Base &b)
Definition base_p.h:17
std::queue< EventDispatcher::IdleFunction > _idleFuncs
std::vector< std::shared_ptr< void > > _unrefLater
static void waitPidCallback(GPid pid, gint status, gpointer user_data)
std::unordered_map< int, GlibWaitPIDData > _waitPIDs
std::vector< GAbstractEventSource * > _eventSources
UnixSignalSourceWeakRef _signalSource
std::vector< GLibTimerSource * > _runningTimers
EventDispatcherPrivate(GMainContext *ctx, EventDispatcher &p)
static std::shared_ptr< EventDispatcher > create()
std::function< void(int, int)> WaitPidCallback
The Timer class provides repetitive and single-shot timers.
Definition timer.h:45
static gboolean check(GSource *source)
std::vector< GUnixPollFD > pollfds
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
static GAbstractEventSource * create(EventDispatcherPrivate *ev)
static void destruct(GAbstractEventSource *src)
static gboolean prepare(GSource *, gint *timeout)
static void destruct(GLibTimerSource *src)
static gboolean prepare(GSource *src, gint *timeout)
static gboolean check(GSource *source)
static GLibTimerSource * create()
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
GlibWaitPIDData & operator=(GlibWaitPIDData &&other) noexcept
EventDispatcher::WaitPidCallback callback
#define ZYPP_DECLARE_PUBLIC(Class)
Definition zyppglobal.h:98
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126