libzypp  17.22.0
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 
11 namespace zyppng {
12 
14 {
15  GIOCondition reqEvents;
16  int pollfd = -1;
17  gpointer tag = nullptr;
18 };
19 
27 {
28  GSource source;
31  std::vector<GUnixPollFD> pollfds;
32 
33  static gboolean prepare(GSource *, gint *timeout);
34  static gboolean check(GSource *source);
35  static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
36 
38  static void destruct ( GAbstractEventSource *src );
39 };
40 
48 {
49  GSource source;
50  Timer *_t = nullptr;
51 
52  static gboolean prepare(GSource *src, gint *timeout);
53  static gboolean check(GSource *source);
54  static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
55 
56  static GLibTimerSource *create ();
57  static void destruct ( GLibTimerSource *src );
58 };
59 
61 {
62 public:
64  EventDispatcherPrivate( GMainContext *ctx );
65  virtual ~EventDispatcherPrivate();
66 
67  bool runIdleTasks();
68  void enableIdleSource ();
69 
70  std::thread::id _myThreadId;
71  GMainLoop *_loop = nullptr;
72  GMainContext *_ctx = nullptr;
73 
74  GSource *_idleSource = nullptr;
75 
76  std::vector<GLibTimerSource *> _runningTimers;
77  std::vector<GAbstractEventSource *> _eventSources;
78  std::vector< std::shared_ptr<void> > _unrefLater;
79  std::queue< EventDispatcher::IdleFunction > _idleFuncs;
80 };
81 
82 }
83 
84 
85 #endif
std::vector< std::shared_ptr< void > > _unrefLater
std::vector< GAbstractEventSource * > _eventSources
static void destruct(GAbstractEventSource *src)
static gboolean check(GSource *source)
static GLibTimerSource * create()
static void destruct(GLibTimerSource *src)
time_t timeout
Definition: MediaCurl.cc:66
The Timer class provides repetitive and single-shot timers.
Definition: timer.h:42
std::vector< GLibTimerSource * > _runningTimers
EventDispatcherPrivate * _ev
static gboolean prepare(GSource *, gint *timeout)
std::vector< GUnixPollFD > pollfds
std::queue< EventDispatcher::IdleFunction > _idleFuncs
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
static gboolean prepare(GSource *src, gint *timeout)
static GAbstractEventSource * create(EventDispatcherPrivate *ev)
#define ZYPP_DECLARE_PUBLIC(Class)
Definition: zyppglobal.h:39
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
static gboolean check(GSource *source)