itsignaler

itsignaler

Types and Values

Description

Functions

itsignaler_new ()

ITSignaler *
itsignaler_new (void);

Creates a new ITSignaler object.

Returns

a new ITSignaler, or NULL if an error occurred. Use itsignaler_unref() when not needed anymore.


itsignaler_windows_get_poll_fd ()

SOCKET
itsignaler_windows_get_poll_fd (ITSignaler *its);

Get the socket descriptor associated to its .

Parameters

its

a ITSignaler object

 

Returns

the file descriptor number, or -1 on error


itsignaler_unix_get_poll_fd ()

int
itsignaler_unix_get_poll_fd (ITSignaler *its);

Get the file descriptor associated to its .

Parameters

its

a ITSignaler object

 

Returns

the file descriptor number, or -1 on error


itsignaler_ref ()

ITSignaler *
itsignaler_ref (ITSignaler *its);

Increases the reference count of its . If its is NULL, then nothing happens.

This function can be called from any thread.

Parameters

its

a ITSignaler object.

[allow-none]

Returns

its


itsignaler_unref ()

void
itsignaler_unref (ITSignaler *its);

Decrease the reference count of its ; when the rerefence count reaches zero, the object is freed. If its is NULL, then nothing happens.

This function can be called from any thread.

Parameters

its

a ITSignaler object.

[allow-none]

itsignaler_push_notification ()

gboolean
itsignaler_push_notification (ITSignaler *its,
                              gpointer data,
                              GDestroyNotify destroy_func);

Use this function to push a notification.

Note that data will be passes AS-IS to the thread which calls itsignaler_pop_notification(), any memory allocation must be handled correctly by the caller. However, in case itsignaler_unref() is called while there are still some undelivered notifications, each notification's data will be freed using the destroy_func which was specified when itsignaler_push_notification() was called (note that no warning of any sort will be shown if destroy_func is NULL and some notification data should have been freed).

Parameters

its

a ITSignaler pointer

 

data

a pointer to some data.

 

destroy_func

a function to be called to free data , or NULL.

[allow-none]

Returns

TRUE if no error occurred


itsignaler_pop_notification ()

gpointer
itsignaler_pop_notification (ITSignaler *its,
                             gint timeout_ms);

Use this function from the thread to be signaled, to fetch any pending notification. If no notification is available, then this function returns immediately NULL. It's up to the caller to free the returned data.

Parameters

its

a ITSignaler object

 

timeout_ms

if set to 0, then the function returns immediately if there is no notification, if set to a negative value, then this function blocks until a notification becomes available, otherwise maximum number of miliseconds to wait for a notification.

 

Returns

a pointer to some data which has been pushed by the notifying thread using itsignaler_push_notification(), or NULL if no notification is present.


itsignaler_create_source ()

GSource *
itsignaler_create_source (ITSignaler *its);

Create a new GSource for its .

The source will not initially be associated with any GMainContext and must be added to one with g_source_attach() before it will be executed.

Parameters

its

a ITSignaler object

 

Returns

a new GSource.


ITSignalerFunc ()

gboolean
(*ITSignalerFunc) (ITSignaler *its,
                   gpointer user_data);

itsignaler_add ()

guint
itsignaler_add (ITSignaler *its,
                GMainContext *context,
                ITSignalerFunc func,
                gpointer data,
                GDestroyNotify notify);

Have its call func (with data ) in the context of context . Remove using itsignaler_remove(). This function is similar to itsignaler_create_source() but is packaged for easier usage.

Use itsignaler_remove() to undo this function.

Parameters

its

a ITSignaler object

 

context

a GMainContext (if NULL, the default context will be used).

[allow-none]

func

callback function to be called when a notification is ready

 

data

data to pass to func

 

notify

a function to call when data is no longer in use, or NULL.

[allow-none]

Returns

the ID (greater than 0) for the source within the GMainContext.


itsignaler_remove ()

gboolean
itsignaler_remove (ITSignaler *its,
                   GMainContext *context,
                   guint id);

Does the reverse of itsignaler_add().

Parameters

its

a ITSignaler object

 

context

a GMainContext (if NULL, the default context will be used).

[allow-none]

id

the ID of the source as returned by itsignaler_add()

 

Returns

TRUE if the source has been removed

Types and Values

ITSignaler

typedef struct _ITSignaler ITSignaler;