GdaConnect: libgda Reference Manual

## GdaConnect GdaConnect — Inter thread signal propagation |

## Stability Level

Stable, unless otherwise indicated

## Functions

gulong | gda_signal_connect ()
void | gda_signal_handler_disconnect ()

## Includes

    #include <libgda/gda-statement-extra.h>

## Description

The purpose of the `gda_signal_connect()` is to allow one to connect to a signal emitted by an object and be sure that the acutal signal handling will occur _only_ when running a specific GMainContext. The `gda_signal_handler_disconnect()` actually disconnects the handler.

Use these functions for exemple when you need to handle signals from objects which are emitted from within a thread which is not the main UI thread.

These function implement their own locking mechanism and can safely be used from multiple threads at once without needing further locking.

## Functions

### gda_signal_connect ()

    gulong
    gda_signal_connect (gpointer instance,
                        const gchar *detailed_signal,
                        GCallback c_handler,
                        gpointer data,
                        GClosureNotify destroy_data,
                        GConnectFlags connect_flags,
                        GMainContext *context);

Connects a GCallback function to a signal for a particular object. The difference with `g_signal_connect()` is that the callback will be called from withing the thread which is the owner of `context` . If needed you may have to use `g_main_context_acquire()` to ensure a specific thread is the owner of `context` .

#### Parameters

instance | the instance to connect to |
detailed_signal | a string of the form "signal-name::detail" |
c_handler | the GCallback to connect |
data | data to pass to `c_handler` , or `NULL`. | [nullable]
destroy_data | function to destroy `data` when not needed anymore, or `NULL`. | [nullable]
connect_flags | a combination of GConnectFlags. |
context | the GMainContext in which signals will actually be treated, or `NULL` for the default one. | [nullable]

#### Returns

the handler id, or `0` if an error occurred

Since: 6.0

### gda_signal_handler_disconnect ()

    void
    gda_signal_handler_disconnect (gpointer instance,
                                   gulong handler_id);

Disconnect a callback using the signal handler, see `gda_signal_connect()`. This function is similar to calling `g_signal_handler_disconnect()`.

#### Parameters

instance | the instance to disconnect from |
handler_id | the signal handler, as returned by `gda_signal_connect()` |

Since: 6.0