InfStandaloneIo

InfStandaloneIo — Simple event loop implementation

Stability Level

Unstable, unless otherwise indicated

Synopsis

#include <libinfinity/common/inf-standalone-io.h>

                    InfStandaloneIo;
struct              InfStandaloneIoClass;
InfStandaloneIo *   inf_standalone_io_new               (void);
void                inf_standalone_io_iteration         (InfStandaloneIo *io);
void                inf_standalone_io_iteration_timeout (InfStandaloneIo *io,
                                                         guint timeout);
void                inf_standalone_io_loop              (InfStandaloneIo *io);
void                inf_standalone_io_loop_quit         (InfStandaloneIo *io);
gboolean            inf_standalone_io_loop_running      (InfStandaloneIo *io);

Object Hierarchy

  GObject
   +----InfStandaloneIo

Implemented Interfaces

InfStandaloneIo implements InfIo.

Description

InfStandaloneIo is a simple implementation of the InfIo interface. It implements a basic application event loop with support for listening on sockets, scheduling timeouts and inter-thread notifications. The class is fully thread-safe.

This class can be perfectly used for all functions in libinfinity that require a InfIo object to wait for events. If, on top of that more functionality is required, or the main loop needs to be integrated with another library such as a UI toolkit, a custom class should be created instead which implements the InfIo interface. For the GTK+ toolkit, there is InfGtkIo in the libinfgtk library, to integrate with the Glib main loop.

Details

InfStandaloneIo

typedef struct _InfStandaloneIo InfStandaloneIo;

InfStandaloneIo is an opaque data type. You should only access it via the public API functions.


struct InfStandaloneIoClass

struct InfStandaloneIoClass {
};

This structure does not contain any public fields.


inf_standalone_io_new ()

InfStandaloneIo *   inf_standalone_io_new               (void);

Creates a new InfStandaloneIo.

Returns :

A new InfStandaloneIo. Free with g_object_unref() when no longer needed.

inf_standalone_io_iteration ()

void                inf_standalone_io_iteration         (InfStandaloneIo *io);

Performs a single iteration of io. The call will block until a first event has occured. Then, it will process that event and return.

io :

A InfStandaloneIo.

inf_standalone_io_iteration_timeout ()

void                inf_standalone_io_iteration_timeout (InfStandaloneIo *io,
                                                         guint timeout);

Performs a single iteration of io. The call will block until either an event occured or timeout milliseconds have elapsed. If an event occured, the event will be processed before returning.

io :

A InfStandaloneIo.

timeout :

Maximum number of milliseconds to block.

inf_standalone_io_loop ()

void                inf_standalone_io_loop              (InfStandaloneIo *io);

This call will cause io to wait for events and process them, but not return until inf_standalone_io_loop_quit() is called.

io :

A InfStandaloneIo.

inf_standalone_io_loop_quit ()

void                inf_standalone_io_loop_quit         (InfStandaloneIo *io);

Exits a loop in which io is running through a call to inf_standalone_io_loop().

io :

A InfStandaloneIo.

inf_standalone_io_loop_running ()

gboolean            inf_standalone_io_loop_running      (InfStandaloneIo *io);

Returns whether io runs currently in a loop initiated with inf_standalone_io_loop().

io :

A InfStandaloneIo.

Returns :

Whether io runs in a loop.

See Also

InfIo