1 #ifndef ZYPP_BASE_EVENTDISPATCHER_GLIB_P_DEFINED
2 #define ZYPP_BASE_EVENTDISPATCHER_GLIB_P_DEFINED
5 #include <zypp/zyppng/base/eventdispatcher.h>
8 #include <unordered_map>
15 GIOCondition reqEvents;
17 gpointer tag = nullptr;
21 * \internal GSource for all AbstractEventSources
22 * \attention this struct is initialized with malloc, make sure
23 * to manually call all constructurs and destructors in the
24 * \a create and \a destruct functions
26 struct GAbstractEventSource
29 AbstractEventSource *eventSource;
30 EventDispatcherPrivate *_ev;
31 std::vector<GUnixPollFD> pollfds;
33 static gboolean prepare(GSource *, gint *timeout);
34 static gboolean check(GSource *source);
35 static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
37 static GAbstractEventSource *create (EventDispatcherPrivate *ev);
38 static void destruct ( GAbstractEventSource *src );
42 * \internal GSource for all Timers
43 * \attention this struct is initialized with malloc, make sure
44 * to manually call all constructurs and destructors in the
45 * \a create and \a destruct functions
47 struct GLibTimerSource
52 static gboolean prepare(GSource *src, gint *timeout);
53 static gboolean check(GSource *source);
54 static gboolean dispatch(GSource *source, GSourceFunc, gpointer);
56 static GLibTimerSource *create ();
57 static void destruct ( GLibTimerSource *src );
60 class EventDispatcherPrivate : public BasePrivate
63 ZYPP_DECLARE_PUBLIC(EventDispatcher)
64 EventDispatcherPrivate( GMainContext *ctx );
65 virtual ~EventDispatcherPrivate();
68 void enableIdleSource ();
70 std::thread::id _myThreadId;
71 GMainLoop *_loop = nullptr;
72 GMainContext *_ctx = nullptr;
74 GSource *_idleSource = nullptr;
76 std::vector<GLibTimerSource *> _runningTimers;
77 std::vector<GAbstractEventSource *> _eventSources;
78 std::vector< std::shared_ptr<void> > _unrefLater;
79 std::queue< EventDispatcher::IdleFunction > _idleFuncs;