25 #ifndef CARGO_IPC_IPC_GSOURCE_HPP
26 #define CARGO_IPC_IPC_GSOURCE_HPP
54 typedef std::shared_ptr<IPCGSource>
Pointer;
82 guint
attach(GMainContext* context =
nullptr);
110 typedef std::unique_lock<std::recursive_mutex>
Lock;
115 static gboolean
prepare(GSource* source, gint* timeout);
120 static gboolean
check(GSource* source);
125 static gboolean
dispatch(GSource* source,
126 GSourceFunc callbacks,
132 static void finalize(GSource* source);
148 #endif // CARGO_IPC_IPC_GSOURCE_HPP
std::list< GPollFD > mGPollFDs
Definition: ipc-gsource.hpp:139
static gboolean prepare(GSource *source, gint *timeout)
GSourceFuncs' callback.
Definition: ipc-gsource.cpp:161
GSource mGSource
Definition: ipc-gsource.hpp:137
static void finalize(GSource *source)
GSourceFuncs' callback.
Definition: ipc-gsource.cpp:199
Class for connecting to the glib's loop.
Definition: ipc-gsource.hpp:51
~IPCGSource()
Definition: ipc-gsource.cpp:51
Callback guard.
Definition: callback-guard.hpp:38
void callHandler()
Locks the internal state mutex and calls the handler callback for each fd.
Definition: ipc-gsource.cpp:141
static gboolean check(GSource *source)
GSourceFuncs' callback.
Definition: ipc-gsource.cpp:174
static gboolean onHandlerCall(gpointer userData)
Callback for the dispatch function.
Definition: ipc-gsource.cpp:152
void addFD(const FileDescriptor peerFD)
New file descriptor to listen on.
Definition: ipc-gsource.cpp:91
static Pointer create(const HandlerCallback &handlerCallback)
Creates the IPCGSource class in the memory allocated by glib.
Definition: ipc-gsource.cpp:56
utils::CallbackGuard mGuard
Definition: ipc-gsource.hpp:140
void detach()
After this method quits handlerCallback will not be called.
Definition: ipc-gsource.cpp:124
IPCGSource & operator=(const IPCGSource &)=delete
std::unique_lock< std::recursive_mutex > Lock
Definition: ipc-gsource.hpp:110
std::shared_ptr< IPCGSource > Pointer
Definition: ipc-gsource.hpp:54
std::function< void(FileDescriptor fd, short pollEvent)> HandlerCallback
Definition: ipc-gsource.hpp:53
void removeFD(const FileDescriptor peerFD)
Removes the file descriptor from the GSource.
Definition: ipc-gsource.cpp:100
guint attach(GMainContext *context=nullptr)
Attach to the glib's GMainContext.
Definition: ipc-gsource.cpp:117
int FileDescriptor
Definition: types.hpp:42
HandlerCallback mHandlerCallback
Definition: ipc-gsource.hpp:138
std::recursive_mutex mStateMutex
Definition: ipc-gsource.hpp:141
static gboolean dispatch(GSource *source, GSourceFunc callbacks, gpointer userData)
GSourceFuncs' callback.
Definition: ipc-gsource.cpp:183