Gda.ThreadNotification

Fields

Name

Type

Access

Description

job_id

int

r/w

the job ID, if type is a Gda.ThreadNotificationType.JOB

type

Gda.ThreadNotificationType

r/w

the notification type

Methods

None

Details

class Gda.ThreadNotification

A notification to be read through the GLib.IOChannel which is returned by Gda.ThreadWrapper.get_io_channel(), for example:

gboolean
wrapper_ioc_cb (GIOChannel *source, GIOCondition condition, gpointer data)
{
    GIOStatus status;
    gsize nread;
    GdaThreadNotification notif;
    if (condition & G_IO_IN) {
   status = g_io_channel_read_chars (source, (gchar*) &notif, sizeof (notif), &nread, NULL);
        if ((status != G_IO_STATUS_NORMAL) || (nread != sizeof (notif)))
            goto onerror;
   switch (notif.type) {
   case GDA_THREAD_NOTIFICATION_JOB:
            check_for_wrapper_result (bcnc);
            break;
        case GDA_THREAD_NOTIFICATION_SIGNAL:
            gda_thread_wrapper_iterate (bcnc->priv->wrapper, FALSE);
            break;
        default:
            goto onerror;
            break;
   }
  }
  if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
            goto onerror;
  return TRUE; // keep callback

onerror:
  g_io_channel_shutdown (bcnc->priv->ioc, FALSE, NULL);
  return FALSE; // removed callback
}

{
[...]
    GIOChannel *ioc;
    ioc = gda_thread_wrapper_get_io_channel (wrapper);
    if (!ioc)
        [handle error]
    else {
        guint watch_id;
        watch_id = g_io_add_watch (ioc, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
                                   (GIOFunc) wrapper_ioc_cb, NULL);
    }
}