glibmm 2.82.0
|
#include <glibmm/main.h>
Public Types | |
using | CppObjectType = Glib::Source |
using | BaseObjectType = GSource |
Public Member Functions | |
Source (const Source &)=delete | |
Source & | operator= (const Source &)=delete |
unsigned int | attach (const Glib::RefPtr< MainContext > &context) |
Adds a Source to a context so that it will be executed within that context. | |
unsigned int | attach () |
Adds a Source to a context so that it will be executed within that context. | |
void | destroy () |
Removes a source from its MainContext, if any, and marks it as destroyed. | |
void | set_priority (int priority) |
Sets the priority of a source. | |
int | get_priority () const |
Gets the priority of a source. | |
void | set_can_recurse (bool can_recurse) |
Sets whether a source can be called recursively. | |
bool | get_can_recurse () const |
Checks whether a source is allowed to be called recursively. | |
unsigned int | get_id () const |
Returns the numeric ID for a particular source. | |
Glib::RefPtr< MainContext > | get_context () |
Gets the MainContext with which the source is associated. | |
GSource * | gobj () |
const GSource * | gobj () const |
GSource * | gobj_copy () const |
void | reference () const |
void | unreference () const |
Static Public Member Functions | |
static Glib::RefPtr< Source > | create () |
Protected Member Functions | |
Source () | |
Construct an object that uses the virtual functions prepare(), check() and dispatch(). | |
Source (GSource *cast_item, GSourceFunc callback_func) | |
Wrap an existing GSource object and install the given callback function. | |
virtual | ~Source () noexcept |
sigc::connection | connect_generic (const sigc::slot_base &slot) |
void | add_poll (PollFD &poll_fd) |
Adds a file descriptor to the set of file descriptors polled for this source. | |
void | remove_poll (PollFD &poll_fd) |
Removes a file descriptor from the set of file descriptors polled for this source. | |
gint64 | get_time () const |
Gets the time to be used when checking this source. | |
virtual bool | prepare (int &timeout)=0 |
virtual bool | check ()=0 |
virtual bool | dispatch (sigc::slot_base *slot)=0 |
|
protected |
Construct an object that uses the virtual functions prepare(), check() and dispatch().
|
protected |
Wrap an existing GSource object and install the given callback function.
The constructed object doesn't use the virtual functions prepare(), check() and dispatch(). This constructor is for use by derived types that need to wrap a GSource object. The callback function is called from GLib (a C library). It shall have C linkage. (Many compilers accept a function with C++ linkage. If you use only such compilers, the callback function can be a static member function.) But beware - depending on the actual implementation of the GSource's virtual functions the expected type of the callback function can differ from GSourceFunc.
|
protectedvirtualnoexcept |
Adds a Source to a context so that it will be executed within that context.
The default context will be used.
unsigned int Glib::Source::attach | ( | const Glib::RefPtr< MainContext > & | context | ) |
Adds a Source to a context so that it will be executed within that context.
context | A MainContext. |
|
protectedpure virtual |
Implemented in Glib::TimeoutSource, Glib::IdleSource, and Glib::IOSource.
|
protected |
|
static |
void Glib::Source::destroy | ( | ) |
Removes a source from its MainContext, if any, and marks it as destroyed.
The source cannot be subsequently added to another context.
|
protectedpure virtual |
Implemented in Glib::TimeoutSource, Glib::IOSource, and Glib::IdleSource.
bool Glib::Source::get_can_recurse | ( | ) | const |
Checks whether a source is allowed to be called recursively.
see set_can_recurse().
Glib::RefPtr< MainContext > Glib::Source::get_context | ( | ) |
Gets the MainContext with which the source is associated.
Calling this function on a destroyed source is an error.
Returns the numeric ID for a particular source.
The ID of a source is unique within a particular main loop context. The reverse mapping from ID to source is done by MainContext::find_source_by_id().
int Glib::Source::get_priority | ( | ) | const |
Gets the priority of a source.
|
protected |
Gets the time to be used when checking this source.
The advantage of calling this function over calling g_get_monotonic_time() directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system monotonic time.
The time here is the system monotonic time, if available, or some other reasonable alternative otherwise. See g_get_monotonic_time().
|
inline |
GSource * Glib::Source::gobj_copy | ( | ) | const |
Implemented in Glib::TimeoutSource, Glib::IdleSource, and Glib::IOSource.
void Glib::Source::reference | ( | ) | const |
Removes a file descriptor from the set of file descriptors polled for this source.
poll_fd | A PollFD object previously passed to add_poll(). |
void Glib::Source::set_can_recurse | ( | bool | can_recurse | ) |
Sets whether a source can be called recursively.
If can_recurse is true, then while the source is being dispatched then this source will be processed normally. Otherwise, all processing of this source is blocked until the dispatch function returns.
can_recurse | Whether recursion is allowed for this source. |
Sets the priority of a source.
While the main loop is being run, a source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched.
priority | The new priority. |
void Glib::Source::unreference | ( | ) | const |