static CK_RV perform_call (GckPerformFunc func, GCancellable *cancellable, GckArguments *args) { CK_RV rv; /* Double check a few things */ g_assert (func); g_assert (args); if (cancellable) { if (g_cancellable_is_cancelled (cancellable)) { return CKR_FUNCTION_CANCELED; } /* Push for the notify callback */ g_object_ref (cancellable); g_cancellable_push_current (cancellable); } rv = (func) (args); if (cancellable) { g_cancellable_pop_current (cancellable); g_object_unref (cancellable); } return rv; }
static gboolean run_job_at_idle (gpointer data) { GIOSchedulerJob *job = data; gboolean result; if (job->cancellable) g_cancellable_push_current (job->cancellable); result = job->job_func (job, job->cancellable, job->data); if (job->cancellable) g_cancellable_pop_current (job->cancellable); return result; }
static void io_job_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { GIOSchedulerJob *job = task_data; gboolean result; if (job->cancellable) g_cancellable_push_current (job->cancellable); do { result = job->job_func (job, job->cancellable, job->data); } while (result); if (job->cancellable) g_cancellable_pop_current (job->cancellable); }
static void io_job_thread (gpointer data, gpointer user_data) { GIOSchedulerJob *job = data; gboolean result; if (job->cancellable) g_cancellable_push_current (job->cancellable); do { result = job->job_func (job, job->cancellable, job->data); } while (result); if (job->cancellable) g_cancellable_pop_current (job->cancellable); job_destroy (job); }
/** * g_pollable_input_stream_read_nonblocking: * @stream: a #GPollableInputStream * @buffer: a buffer to read data into (which should be at least @count * bytes long). * @count: the number of bytes you want to read * @cancellable: (allow-none): a #GCancellable, or %NULL * @error: #GError for error reporting, or %NULL to ignore. * * Attempts to read up to @count bytes from @stream into @buffer, as * with g_input_stream_read(). If @stream is not currently readable, * this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can * use g_pollable_input_stream_create_source() to create a #GSource * that will be triggered when @stream is readable. * * Note that since this method never blocks, you cannot actually * use @cancellable to cancel it. However, it will return an error * if @cancellable has already been cancelled when you call, which * may happen if you call this method after a source triggers due * to having been cancelled. * * Virtual: read_nonblocking * Returns: the number of bytes read, or -1 on error (including * %G_IO_ERROR_WOULD_BLOCK). */ gssize g_pollable_input_stream_read_nonblocking (GPollableInputStream *stream, void *buffer, gsize count, GCancellable *cancellable, GError **error) { gssize res; g_return_val_if_fail (G_IS_POLLABLE_INPUT_STREAM (stream), -1); g_return_val_if_fail (buffer != NULL, 0); if (g_cancellable_set_error_if_cancelled (cancellable, error)) return -1; if (count == 0) return 0; if (((gssize) count) < 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, _("Too large count value passed to %s"), G_STRFUNC); return -1; } if (cancellable) g_cancellable_push_current (cancellable); res = G_POLLABLE_INPUT_STREAM_GET_INTERFACE (stream)-> read_nonblocking (stream, buffer, count, error); if (cancellable) g_cancellable_pop_current (cancellable); return res; }