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
eventdispatcher.h
zyppng::BasePrivate
Definition: base_p.h:12
zyppng::GAbstractEventSource::dispatch
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
Definition: eventdispatcher_glib.cc:105
zyppng::GLibTimerSource::dispatch
static gboolean dispatch(GSource *source, GSourceFunc, gpointer)
Definition: eventdispatcher_glib.cc:185
zyppng::GLibTimerSource::_t
Timer * _t
Definition: eventdispatcher_glib_p.h:50
zyppng::EventDispatcher
Definition: eventdispatcher.h:49
zyppng::GLibTimerSource::check
static gboolean check(GSource *source)
Definition: eventdispatcher_glib.cc:179
zyppng::GUnixPollFD::pollfd
int pollfd
Definition: eventdispatcher_glib_p.h:16
zyppng::GAbstractEventSource::_ev
EventDispatcherPrivate * _ev
Definition: eventdispatcher_glib_p.h:30
zyppng::GAbstractEventSource::destruct
static void destruct(GAbstractEventSource *src)
Definition: eventdispatcher_glib.cc:52
zyppng::EventDispatcherPrivate::_loop
GMainLoop * _loop
Definition: eventdispatcher_glib_p.h:71
zyppng::EventDispatcherPrivate::_unrefLater
std::vector< std::shared_ptr< void > > _unrefLater
Definition: eventdispatcher_glib_p.h:78
zyppng::GAbstractEventSource::check
static gboolean check(GSource *source)
Definition: eventdispatcher_glib.cc:75
zyppng::GUnixPollFD::tag
gpointer tag
Definition: eventdispatcher_glib_p.h:17
zyppng::EventDispatcherPrivate::~EventDispatcherPrivate
virtual ~EventDispatcherPrivate()
Definition: eventdispatcher_glib.cc:253
zyppng::GLibTimerSource
Definition: eventdispatcher_glib_p.h:47
zyppng::EventDispatcherPrivate
Definition: eventdispatcher_glib_p.h:60
zyppng::GAbstractEventSource::create
static GAbstractEventSource * create(EventDispatcherPrivate *ev)
Definition: eventdispatcher_glib.cc:42
zyppng::AbstractEventSource
Definition: abstracteventsource.h:37
zyppng::EventDispatcherPrivate::_idleFuncs
std::queue< EventDispatcher::IdleFunction > _idleFuncs
Definition: eventdispatcher_glib_p.h:79
zyppng::EventDispatcherPrivate::runIdleTasks
bool runIdleTasks()
Definition: eventdispatcher_glib.cc:271
zyppng::GAbstractEventSource::source
GSource source
Definition: eventdispatcher_glib_p.h:28
zyppng::GLibTimerSource::create
static GLibTimerSource * create()
Definition: eventdispatcher_glib.cc:199
base_p.h
zyppng::GAbstractEventSource
Definition: eventdispatcher_glib_p.h:26
zyppng::Timer
The Timer class provides repetitive and single-shot timers.
Definition: timer.h:42
zyppng::EventDispatcherPrivate::_idleSource
GSource * _idleSource
Definition: eventdispatcher_glib_p.h:74
zyppng::GLibTimerSource::source
GSource source
Definition: eventdispatcher_glib_p.h:49
zyppng::EventDispatcherPrivate::EventDispatcherPrivate
EventDispatcherPrivate(GMainContext *ctx)
Definition: eventdispatcher_glib.cc:228
zyppng::EventDispatcherPrivate::_eventSources
std::vector< GAbstractEventSource * > _eventSources
Definition: eventdispatcher_glib_p.h:77
ZYPP_DECLARE_PUBLIC
#define ZYPP_DECLARE_PUBLIC(Class)
Definition: zyppglobal.h:39
zyppng::GAbstractEventSource::pollfds
std::vector< GUnixPollFD > pollfds
Definition: eventdispatcher_glib_p.h:31
zyppng::EventDispatcherPrivate::enableIdleSource
void enableIdleSource()
Definition: eventdispatcher_glib.cc:293
zyppng::EventDispatcherPrivate::_ctx
GMainContext * _ctx
Definition: eventdispatcher_glib_p.h:72
zyppng::EventDispatcherPrivate::_runningTimers
std::vector< GLibTimerSource * > _runningTimers
Definition: eventdispatcher_glib_p.h:76
timeout
time_t timeout
Definition: MediaCurl.cc:66
zyppng::GUnixPollFD::reqEvents
GIOCondition reqEvents
Definition: eventdispatcher_glib_p.h:15
zyppng::GAbstractEventSource::eventSource
AbstractEventSource * eventSource
Definition: eventdispatcher_glib_p.h:29
zyppng::GUnixPollFD
Definition: eventdispatcher_glib_p.h:13
zyppng
Definition: abstracteventsource.cc:8
zyppng::GAbstractEventSource::prepare
static gboolean prepare(GSource *, gint *timeout)
Definition: eventdispatcher_glib.cc:65
zyppng::GLibTimerSource::prepare
static gboolean prepare(GSource *src, gint *timeout)
Definition: eventdispatcher_glib.cc:158
zyppng::GLibTimerSource::destruct
static void destruct(GLibTimerSource *src)
Definition: eventdispatcher_glib.cc:207
zyppng::EventDispatcherPrivate::_myThreadId
std::thread::id _myThreadId
Definition: eventdispatcher_glib_p.h:70