gi-gio-2.0.20: GI/Gio/Objects/Task.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
A 'GI.Gio.Objects.Task.Task' represents and manages a cancellable \"task\".
== Asynchronous operations
The most common usage of 'GI.Gio.Objects.Task.Task' is as a 'GI.Gio.Interfaces.AsyncResult.AsyncResult', to
manage data during an asynchronous operation. You call
'GI.Gio.Objects.Task.taskNew' in the \"start\" method, followed by
'GI.Gio.Objects.Task.taskSetTaskData' and the like if you need to keep some
additional data associated with the task, and then pass the
task object around through your asynchronous operation.
Eventually, you will call a method such as
'GI.Gio.Objects.Task.taskReturnPointer' or 'GI.Gio.Objects.Task.taskReturnError', which will
save the value you give it and then invoke the task\'s callback
function in the
[thread-default main context][g-main-context-push-thread-default]
where it was created (waiting until the next iteration of the main
loop first, if necessary). The caller will pass the 'GI.Gio.Objects.Task.Task' back to
the operation\'s finish function (as a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'), and you can
use 'GI.Gio.Objects.Task.taskPropagatePointer' or the like to extract the
return value.
Here is an example for using GTask as a GAsyncResult:
=== /C code/
>
> typedef struct {
> CakeFrostingType frosting;
> char *message;
> } DecorationData;
>
> static void
> decoration_data_free (DecorationData *decoration)
> {
> g_free (decoration->message);
> g_slice_free (DecorationData, decoration);
> }
>
> static void
> baked_cb (Cake *cake,
> gpointer user_data)
> {
> GTask *task = user_data;
> DecorationData *decoration = g_task_get_task_data (task);
> GError *error = NULL;
>
> if (cake == NULL)
> {
> g_task_return_new_error (task, BAKER_ERROR, BAKER_ERROR_NO_FLOUR,
> "Go to the supermarket");
> g_object_unref (task);
> return;
> }
>
> if (!cake_decorate (cake, decoration->frosting, decoration->message, &error))
> {
> g_object_unref (cake);
> // g_task_return_error() takes ownership of error
> g_task_return_error (task, error);
> g_object_unref (task);
> return;
> }
>
> g_task_return_pointer (task, cake, g_object_unref);
> g_object_unref (task);
> }
>
> void
> baker_bake_cake_async (Baker *self,
> guint radius,
> CakeFlavor flavor,
> CakeFrostingType frosting,
> const char *message,
> GCancellable *cancellable,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> GTask *task;
> DecorationData *decoration;
> Cake *cake;
>
> task = g_task_new (self, cancellable, callback, user_data);
> if (radius < 3)
> {
> g_task_return_new_error (task, BAKER_ERROR, BAKER_ERROR_TOO_SMALL,
> "%ucm radius cakes are silly",
> radius);
> g_object_unref (task);
> return;
> }
>
> cake = _baker_get_cached_cake (self, radius, flavor, frosting, message);
> if (cake != NULL)
> {
> // _baker_get_cached_cake() returns a reffed cake
> g_task_return_pointer (task, cake, g_object_unref);
> g_object_unref (task);
> return;
> }
>
> decoration = g_slice_new (DecorationData);
> decoration->frosting = frosting;
> decoration->message = g_strdup (message);
> g_task_set_task_data (task, decoration, (GDestroyNotify) decoration_data_free);
>
> _baker_begin_cake (self, radius, flavor, cancellable, baked_cb, task);
> }
>
> Cake *
> baker_bake_cake_finish (Baker *self,
> GAsyncResult *result,
> GError **error)
> {
> g_return_val_if_fail (g_task_is_valid (result, self), NULL);
>
> return g_task_propagate_pointer (G_TASK (result), error);
> }
== Chained asynchronous operations
'GI.Gio.Objects.Task.Task' also tries to simplify asynchronous operations that
internally chain together several smaller asynchronous
operations. 'GI.Gio.Objects.Task.taskGetCancellable', 'GI.Gio.Objects.Task.taskGetContext',
and 'GI.Gio.Objects.Task.taskGetPriority' allow you to get back the task\'s
'GI.Gio.Objects.Cancellable.Cancellable', 'GI.GLib.Structs.MainContext.MainContext', and [I\/O priority][io-priority]
when starting a new subtask, so you don\'t have to keep track
of them yourself. @/g_task_attach_source()/@ simplifies the case
of waiting for a source to fire (automatically using the correct
'GI.GLib.Structs.MainContext.MainContext' and priority).
Here is an example for chained asynchronous operations:
=== /C code/
>
> typedef struct {
> Cake *cake;
> CakeFrostingType frosting;
> char *message;
> } BakingData;
>
> static void
> decoration_data_free (BakingData *bd)
> {
> if (bd->cake)
> g_object_unref (bd->cake);
> g_free (bd->message);
> g_slice_free (BakingData, bd);
> }
>
> static void
> decorated_cb (Cake *cake,
> GAsyncResult *result,
> gpointer user_data)
> {
> GTask *task = user_data;
> GError *error = NULL;
>
> if (!cake_decorate_finish (cake, result, &error))
> {
> g_object_unref (cake);
> g_task_return_error (task, error);
> g_object_unref (task);
> return;
> }
>
> // baking_data_free() will drop its ref on the cake, so we have to
> // take another here to give to the caller.
> g_task_return_pointer (task, g_object_ref (cake), g_object_unref);
> g_object_unref (task);
> }
>
> static gboolean
> decorator_ready (gpointer user_data)
> {
> GTask *task = user_data;
> BakingData *bd = g_task_get_task_data (task);
>
> cake_decorate_async (bd->cake, bd->frosting, bd->message,
> g_task_get_cancellable (task),
> decorated_cb, task);
>
> return G_SOURCE_REMOVE;
> }
>
> static void
> baked_cb (Cake *cake,
> gpointer user_data)
> {
> GTask *task = user_data;
> BakingData *bd = g_task_get_task_data (task);
> GError *error = NULL;
>
> if (cake == NULL)
> {
> g_task_return_new_error (task, BAKER_ERROR, BAKER_ERROR_NO_FLOUR,
> "Go to the supermarket");
> g_object_unref (task);
> return;
> }
>
> bd->cake = cake;
>
> // Bail out now if the user has already cancelled
> if (g_task_return_error_if_cancelled (task))
> {
> g_object_unref (task);
> return;
> }
>
> if (cake_decorator_available (cake))
> decorator_ready (task);
> else
> {
> GSource *source;
>
> source = cake_decorator_wait_source_new (cake);
> // Attach @source to @task's GMainContext and have it call
> // decorator_ready() when it is ready.
> g_task_attach_source (task, source, decorator_ready);
> g_source_unref (source);
> }
> }
>
> void
> baker_bake_cake_async (Baker *self,
> guint radius,
> CakeFlavor flavor,
> CakeFrostingType frosting,
> const char *message,
> gint priority,
> GCancellable *cancellable,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> GTask *task;
> BakingData *bd;
>
> task = g_task_new (self, cancellable, callback, user_data);
> g_task_set_priority (task, priority);
>
> bd = g_slice_new0 (BakingData);
> bd->frosting = frosting;
> bd->message = g_strdup (message);
> g_task_set_task_data (task, bd, (GDestroyNotify) baking_data_free);
>
> _baker_begin_cake (self, radius, flavor, cancellable, baked_cb, task);
> }
>
> Cake *
> baker_bake_cake_finish (Baker *self,
> GAsyncResult *result,
> GError **error)
> {
> g_return_val_if_fail (g_task_is_valid (result, self), NULL);
>
> return g_task_propagate_pointer (G_TASK (result), error);
> }
== Asynchronous operations from synchronous ones
You can use @/g_task_run_in_thread()/@ to turn a synchronous
operation into an asynchronous one, by running it in a thread.
When it completes, the result will be dispatched to the
[thread-default main context][g-main-context-push-thread-default]
where the 'GI.Gio.Objects.Task.Task' was created.
Running a task in a thread:
=== /C code/
>
> typedef struct {
> guint radius;
> CakeFlavor flavor;
> CakeFrostingType frosting;
> char *message;
> } CakeData;
>
> static void
> cake_data_free (CakeData *cake_data)
> {
> g_free (cake_data->message);
> g_slice_free (CakeData, cake_data);
> }
>
> static void
> bake_cake_thread (GTask *task,
> gpointer source_object,
> gpointer task_data,
> GCancellable *cancellable)
> {
> Baker *self = source_object;
> CakeData *cake_data = task_data;
> Cake *cake;
> GError *error = NULL;
>
> cake = bake_cake (baker, cake_data->radius, cake_data->flavor,
> cake_data->frosting, cake_data->message,
> cancellable, &error);
> if (cake)
> g_task_return_pointer (task, cake, g_object_unref);
> else
> g_task_return_error (task, error);
> }
>
> void
> baker_bake_cake_async (Baker *self,
> guint radius,
> CakeFlavor flavor,
> CakeFrostingType frosting,
> const char *message,
> GCancellable *cancellable,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> CakeData *cake_data;
> GTask *task;
>
> cake_data = g_slice_new (CakeData);
> cake_data->radius = radius;
> cake_data->flavor = flavor;
> cake_data->frosting = frosting;
> cake_data->message = g_strdup (message);
> task = g_task_new (self, cancellable, callback, user_data);
> g_task_set_task_data (task, cake_data, (GDestroyNotify) cake_data_free);
> g_task_run_in_thread (task, bake_cake_thread);
> g_object_unref (task);
> }
>
> Cake *
> baker_bake_cake_finish (Baker *self,
> GAsyncResult *result,
> GError **error)
> {
> g_return_val_if_fail (g_task_is_valid (result, self), NULL);
>
> return g_task_propagate_pointer (G_TASK (result), error);
> }
== Adding cancellability to uncancellable tasks
Finally, @/g_task_run_in_thread()/@ and @/g_task_run_in_thread_sync()/@
can be used to turn an uncancellable operation into a
cancellable one. If you call 'GI.Gio.Objects.Task.taskSetReturnOnCancel',
passing 'True', then if the task\'s 'GI.Gio.Objects.Cancellable.Cancellable' is cancelled,
it will return control back to the caller immediately, while
allowing the task thread to continue running in the background
(and simply discarding its result when it finally does finish).
Provided that the task thread is careful about how it uses
locks and other externally-visible resources, this allows you
to make \"GLib-friendly\" asynchronous and cancellable
synchronous variants of blocking APIs.
Cancelling a task:
=== /C code/
>
> static void
> bake_cake_thread (GTask *task,
> gpointer source_object,
> gpointer task_data,
> GCancellable *cancellable)
> {
> Baker *self = source_object;
> CakeData *cake_data = task_data;
> Cake *cake;
> GError *error = NULL;
>
> cake = bake_cake (baker, cake_data->radius, cake_data->flavor,
> cake_data->frosting, cake_data->message,
> &error);
> if (error)
> {
> g_task_return_error (task, error);
> return;
> }
>
> // If the task has already been cancelled, then we don't want to add
> // the cake to the cake cache. Likewise, we don't want to have the
> // task get cancelled in the middle of updating the cache.
> // g_task_set_return_on_cancel() will return %TRUE here if it managed
> // to disable return-on-cancel, or %FALSE if the task was cancelled
> // before it could.
> if (g_task_set_return_on_cancel (task, FALSE))
> {
> // If the caller cancels at this point, their
> // GAsyncReadyCallback won't be invoked until we return,
> // so we don't have to worry that this code will run at
> // the same time as that code does. But if there were
> // other functions that might look at the cake cache,
> // then we'd probably need a GMutex here as well.
> baker_add_cake_to_cache (baker, cake);
> g_task_return_pointer (task, cake, g_object_unref);
> }
> }
>
> void
> baker_bake_cake_async (Baker *self,
> guint radius,
> CakeFlavor flavor,
> CakeFrostingType frosting,
> const char *message,
> GCancellable *cancellable,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> CakeData *cake_data;
> GTask *task;
>
> cake_data = g_slice_new (CakeData);
>
> ...
>
> task = g_task_new (self, cancellable, callback, user_data);
> g_task_set_task_data (task, cake_data, (GDestroyNotify) cake_data_free);
> g_task_set_return_on_cancel (task, TRUE);
> g_task_run_in_thread (task, bake_cake_thread);
> }
>
> Cake *
> baker_bake_cake_sync (Baker *self,
> guint radius,
> CakeFlavor flavor,
> CakeFrostingType frosting,
> const char *message,
> GCancellable *cancellable,
> GError **error)
> {
> CakeData *cake_data;
> GTask *task;
> Cake *cake;
>
> cake_data = g_slice_new (CakeData);
>
> ...
>
> task = g_task_new (self, cancellable, NULL, NULL);
> g_task_set_task_data (task, cake_data, (GDestroyNotify) cake_data_free);
> g_task_set_return_on_cancel (task, TRUE);
> g_task_run_in_thread_sync (task, bake_cake_thread);
>
> cake = g_task_propagate_pointer (task, error);
> g_object_unref (task);
> return cake;
> }
== Porting from GSimpleAsyncResult
'GI.Gio.Objects.Task.Task'\'s API attempts to be simpler than 'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'\'s
in several ways:
* You can save task-specific data with 'GI.Gio.Objects.Task.taskSetTaskData', and
retrieve it later with 'GI.Gio.Objects.Task.taskGetTaskData'. This replaces the
abuse of @/g_simple_async_result_set_op_res_gpointer()/@ for the same
purpose with 'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult'.
* In addition to the task data, 'GI.Gio.Objects.Task.Task' also keeps track of the
[priority][io-priority], 'GI.Gio.Objects.Cancellable.Cancellable', and
'GI.GLib.Structs.MainContext.MainContext' associated with the task, so tasks that consist of
a chain of simpler asynchronous operations will have easy access
to those values when starting each sub-task.
* 'GI.Gio.Objects.Task.taskReturnErrorIfCancelled' provides simplified
handling for cancellation. In addition, cancellation
overrides any other 'GI.Gio.Objects.Task.Task' return value by default, like
'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' does when
'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultSetCheckCancellable' is called.
(You can use 'GI.Gio.Objects.Task.taskSetCheckCancellable' to turn off that
behavior.) On the other hand, @/g_task_run_in_thread()/@
guarantees that it will always run your
@task_func@, even if the task\'s 'GI.Gio.Objects.Cancellable.Cancellable'
is already cancelled before the task gets a chance to run;
you can start your @task_func@ with a
'GI.Gio.Objects.Task.taskReturnErrorIfCancelled' check if you need the
old behavior.
* The \"return\" methods (eg, 'GI.Gio.Objects.Task.taskReturnPointer')
automatically cause the task to be \"completed\" as well, and
there is no need to worry about the \"complete\" vs \"complete
in idle\" distinction. ('GI.Gio.Objects.Task.Task' automatically figures out
whether the task\'s callback can be invoked directly, or
if it needs to be sent to another 'GI.GLib.Structs.MainContext.MainContext', or delayed
until the next iteration of the current 'GI.GLib.Structs.MainContext.MainContext'.)
* The \"finish\" functions for 'GI.Gio.Objects.Task.Task' based operations are generally
much simpler than 'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' ones, normally consisting
of only a single call to 'GI.Gio.Objects.Task.taskPropagatePointer' or the like.
Since 'GI.Gio.Objects.Task.taskPropagatePointer' \"steals\" the return value from
the 'GI.Gio.Objects.Task.Task', it is not necessary to juggle pointers around to
prevent it from being freed twice.
* With 'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult', it was common to call
'GI.Gio.Objects.SimpleAsyncResult.simpleAsyncResultPropagateError' from the
@_finish()@ wrapper function, and have
virtual method implementations only deal with successful
returns. This behavior is deprecated, because it makes it
difficult for a subclass to chain to a parent class\'s async
methods. Instead, the wrapper function should just be a
simple wrapper, and the virtual method should call an
appropriate @g_task_propagate_@ function.
Note that wrapper methods can now use
'GI.Gio.Interfaces.AsyncResult.asyncResultLegacyPropagateError' to do old-style
'GI.Gio.Objects.SimpleAsyncResult.SimpleAsyncResult' error-returning behavior, and
'GI.Gio.Interfaces.AsyncResult.asyncResultIsTagged' to check if a result is tagged as
having come from the @_async()@ wrapper
function (for \"short-circuit\" results, such as when passing
0 to 'GI.Gio.Objects.InputStream.inputStreamReadAsync').
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Objects.Task
(
-- * Exported types
Task(..) ,
IsTask ,
toTask ,
noTask ,
-- * Methods
-- ** getCancellable #method:getCancellable#
#if ENABLE_OVERLOADING
TaskGetCancellableMethodInfo ,
#endif
taskGetCancellable ,
-- ** getCheckCancellable #method:getCheckCancellable#
#if ENABLE_OVERLOADING
TaskGetCheckCancellableMethodInfo ,
#endif
taskGetCheckCancellable ,
-- ** getCompleted #method:getCompleted#
#if ENABLE_OVERLOADING
TaskGetCompletedMethodInfo ,
#endif
taskGetCompleted ,
-- ** getContext #method:getContext#
#if ENABLE_OVERLOADING
TaskGetContextMethodInfo ,
#endif
taskGetContext ,
-- ** getName #method:getName#
#if ENABLE_OVERLOADING
TaskGetNameMethodInfo ,
#endif
taskGetName ,
-- ** getPriority #method:getPriority#
#if ENABLE_OVERLOADING
TaskGetPriorityMethodInfo ,
#endif
taskGetPriority ,
-- ** getReturnOnCancel #method:getReturnOnCancel#
#if ENABLE_OVERLOADING
TaskGetReturnOnCancelMethodInfo ,
#endif
taskGetReturnOnCancel ,
-- ** getSourceObject #method:getSourceObject#
#if ENABLE_OVERLOADING
TaskGetSourceObjectMethodInfo ,
#endif
taskGetSourceObject ,
-- ** getSourceTag #method:getSourceTag#
#if ENABLE_OVERLOADING
TaskGetSourceTagMethodInfo ,
#endif
taskGetSourceTag ,
-- ** getTaskData #method:getTaskData#
#if ENABLE_OVERLOADING
TaskGetTaskDataMethodInfo ,
#endif
taskGetTaskData ,
-- ** hadError #method:hadError#
#if ENABLE_OVERLOADING
TaskHadErrorMethodInfo ,
#endif
taskHadError ,
-- ** isValid #method:isValid#
taskIsValid ,
-- ** new #method:new#
taskNew ,
-- ** propagateBoolean #method:propagateBoolean#
#if ENABLE_OVERLOADING
TaskPropagateBooleanMethodInfo ,
#endif
taskPropagateBoolean ,
-- ** propagateInt #method:propagateInt#
#if ENABLE_OVERLOADING
TaskPropagateIntMethodInfo ,
#endif
taskPropagateInt ,
-- ** propagatePointer #method:propagatePointer#
#if ENABLE_OVERLOADING
TaskPropagatePointerMethodInfo ,
#endif
taskPropagatePointer ,
-- ** reportError #method:reportError#
taskReportError ,
-- ** returnBoolean #method:returnBoolean#
#if ENABLE_OVERLOADING
TaskReturnBooleanMethodInfo ,
#endif
taskReturnBoolean ,
-- ** returnError #method:returnError#
#if ENABLE_OVERLOADING
TaskReturnErrorMethodInfo ,
#endif
taskReturnError ,
-- ** returnErrorIfCancelled #method:returnErrorIfCancelled#
#if ENABLE_OVERLOADING
TaskReturnErrorIfCancelledMethodInfo ,
#endif
taskReturnErrorIfCancelled ,
-- ** returnInt #method:returnInt#
#if ENABLE_OVERLOADING
TaskReturnIntMethodInfo ,
#endif
taskReturnInt ,
-- ** returnPointer #method:returnPointer#
#if ENABLE_OVERLOADING
TaskReturnPointerMethodInfo ,
#endif
taskReturnPointer ,
-- ** setCheckCancellable #method:setCheckCancellable#
#if ENABLE_OVERLOADING
TaskSetCheckCancellableMethodInfo ,
#endif
taskSetCheckCancellable ,
-- ** setName #method:setName#
#if ENABLE_OVERLOADING
TaskSetNameMethodInfo ,
#endif
taskSetName ,
-- ** setPriority #method:setPriority#
#if ENABLE_OVERLOADING
TaskSetPriorityMethodInfo ,
#endif
taskSetPriority ,
-- ** setReturnOnCancel #method:setReturnOnCancel#
#if ENABLE_OVERLOADING
TaskSetReturnOnCancelMethodInfo ,
#endif
taskSetReturnOnCancel ,
-- ** setSourceTag #method:setSourceTag#
#if ENABLE_OVERLOADING
TaskSetSourceTagMethodInfo ,
#endif
taskSetSourceTag ,
-- ** setTaskData #method:setTaskData#
#if ENABLE_OVERLOADING
TaskSetTaskDataMethodInfo ,
#endif
taskSetTaskData ,
-- * Properties
-- ** completed #attr:completed#
{- | Whether the task has completed, meaning its callback (if set) has been
invoked. This can only happen after 'GI.Gio.Objects.Task.taskReturnPointer',
'GI.Gio.Objects.Task.taskReturnError' or one of the other return functions have been called
on the task.
This property is guaranteed to change from 'False' to 'True' exactly once.
The 'GI.GObject.Objects.Object.Object'::@/notify/@ signal for this change is emitted in the same main
context as the task’s callback, immediately after that callback is invoked.
/Since: 2.44/
-}
#if ENABLE_OVERLOADING
TaskCompletedPropertyInfo ,
#endif
getTaskCompleted ,
#if ENABLE_OVERLOADING
taskCompleted ,
#endif
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
-- | Memory-managed wrapper type.
newtype Task = Task (ManagedPtr Task)
foreign import ccall "g_task_get_type"
c_g_task_get_type :: IO GType
instance GObject Task where
gobjectType = c_g_task_get_type
-- | Type class for types which can be safely cast to `Task`, for instance with `toTask`.
class (GObject o, O.IsDescendantOf Task o) => IsTask o
instance (GObject o, O.IsDescendantOf Task o) => IsTask o
instance O.HasParentTypes Task
type instance O.ParentTypes Task = '[GObject.Object.Object, Gio.AsyncResult.AsyncResult]
-- | Cast to `Task`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toTask :: (MonadIO m, IsTask o) => o -> m Task
toTask = liftIO . unsafeCastTo Task
-- | A convenience alias for `Nothing` :: `Maybe` `Task`.
noTask :: Maybe Task
noTask = Nothing
#if ENABLE_OVERLOADING
type family ResolveTaskMethod (t :: Symbol) (o :: *) :: * where
ResolveTaskMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveTaskMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveTaskMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveTaskMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveTaskMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveTaskMethod "hadError" o = TaskHadErrorMethodInfo
ResolveTaskMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveTaskMethod "isTagged" o = Gio.AsyncResult.AsyncResultIsTaggedMethodInfo
ResolveTaskMethod "legacyPropagateError" o = Gio.AsyncResult.AsyncResultLegacyPropagateErrorMethodInfo
ResolveTaskMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveTaskMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveTaskMethod "propagateBoolean" o = TaskPropagateBooleanMethodInfo
ResolveTaskMethod "propagateInt" o = TaskPropagateIntMethodInfo
ResolveTaskMethod "propagatePointer" o = TaskPropagatePointerMethodInfo
ResolveTaskMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveTaskMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveTaskMethod "returnBoolean" o = TaskReturnBooleanMethodInfo
ResolveTaskMethod "returnError" o = TaskReturnErrorMethodInfo
ResolveTaskMethod "returnErrorIfCancelled" o = TaskReturnErrorIfCancelledMethodInfo
ResolveTaskMethod "returnInt" o = TaskReturnIntMethodInfo
ResolveTaskMethod "returnPointer" o = TaskReturnPointerMethodInfo
ResolveTaskMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveTaskMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveTaskMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveTaskMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveTaskMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveTaskMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveTaskMethod "getCancellable" o = TaskGetCancellableMethodInfo
ResolveTaskMethod "getCheckCancellable" o = TaskGetCheckCancellableMethodInfo
ResolveTaskMethod "getCompleted" o = TaskGetCompletedMethodInfo
ResolveTaskMethod "getContext" o = TaskGetContextMethodInfo
ResolveTaskMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveTaskMethod "getName" o = TaskGetNameMethodInfo
ResolveTaskMethod "getPriority" o = TaskGetPriorityMethodInfo
ResolveTaskMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveTaskMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveTaskMethod "getReturnOnCancel" o = TaskGetReturnOnCancelMethodInfo
ResolveTaskMethod "getSourceObject" o = TaskGetSourceObjectMethodInfo
ResolveTaskMethod "getSourceTag" o = TaskGetSourceTagMethodInfo
ResolveTaskMethod "getTaskData" o = TaskGetTaskDataMethodInfo
ResolveTaskMethod "getUserData" o = Gio.AsyncResult.AsyncResultGetUserDataMethodInfo
ResolveTaskMethod "setCheckCancellable" o = TaskSetCheckCancellableMethodInfo
ResolveTaskMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveTaskMethod "setName" o = TaskSetNameMethodInfo
ResolveTaskMethod "setPriority" o = TaskSetPriorityMethodInfo
ResolveTaskMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveTaskMethod "setReturnOnCancel" o = TaskSetReturnOnCancelMethodInfo
ResolveTaskMethod "setSourceTag" o = TaskSetSourceTagMethodInfo
ResolveTaskMethod "setTaskData" o = TaskSetTaskDataMethodInfo
ResolveTaskMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveTaskMethod t Task, O.MethodInfo info Task p) => OL.IsLabel t (Task -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
-- VVV Prop "completed"
-- Type: TBasicType TBoolean
-- Flags: [PropertyReadable]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@completed@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' task #completed
@
-}
getTaskCompleted :: (MonadIO m, IsTask o) => o -> m Bool
getTaskCompleted obj = liftIO $ B.Properties.getObjectPropertyBool obj "completed"
#if ENABLE_OVERLOADING
data TaskCompletedPropertyInfo
instance AttrInfo TaskCompletedPropertyInfo where
type AttrAllowedOps TaskCompletedPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint TaskCompletedPropertyInfo = (~) ()
type AttrBaseTypeConstraint TaskCompletedPropertyInfo = IsTask
type AttrGetType TaskCompletedPropertyInfo = Bool
type AttrLabel TaskCompletedPropertyInfo = "completed"
type AttrOrigin TaskCompletedPropertyInfo = Task
attrGet _ = getTaskCompleted
attrSet _ = undefined
attrConstruct _ = undefined
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Task
type instance O.AttributeList Task = TaskAttributeList
type TaskAttributeList = ('[ '("completed", TaskCompletedPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
taskCompleted :: AttrLabelProxy "completed"
taskCompleted = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList Task = TaskSignalList
type TaskSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
-- method Task::new
-- method type : Constructor
-- Args : [Arg {argCName = "source_object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GObject that owns\n this task, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "optional #GCancellable object, %NULL to ignore.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Task"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_task_new" g_task_new ::
Ptr GObject.Object.Object -> -- source_object : TInterface (Name {namespace = "GObject", name = "Object"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
Ptr () -> -- callback_data : TBasicType TPtr
IO (Ptr Task)
{- |
Creates a 'GI.Gio.Objects.Task.Task' acting on /@sourceObject@/, which will eventually be
used to invoke /@callback@/ in the current
[thread-default main context][g-main-context-push-thread-default].
Call this in the \"start\" method of your asynchronous method, and
pass the 'GI.Gio.Objects.Task.Task' around throughout the asynchronous operation. You
can use 'GI.Gio.Objects.Task.taskSetTaskData' to attach task-specific data to the
object, which you can retrieve later via 'GI.Gio.Objects.Task.taskGetTaskData'.
By default, if /@cancellable@/ is cancelled, then the return value of
the task will always be 'GI.Gio.Enums.IOErrorEnumCancelled', even if the task had
already completed before the cancellation. This allows for
simplified handling in cases where cancellation may imply that
other objects that the task depends on have been destroyed. If you
do not want this behavior, you can use
'GI.Gio.Objects.Task.taskSetCheckCancellable' to change it.
/Since: 2.36/
-}
taskNew ::
(B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a, Gio.Cancellable.IsCancellable b) =>
Maybe (a)
{- ^ /@sourceObject@/: the 'GI.GObject.Objects.Object.Object' that owns
this task, or 'Nothing'. -}
-> Maybe (b)
{- ^ /@cancellable@/: optional 'GI.Gio.Objects.Cancellable.Cancellable' object, 'Nothing' to ignore. -}
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
{- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback'. -}
-> m Task
{- ^ __Returns:__ a 'GI.Gio.Objects.Task.Task'. -}
taskNew sourceObject cancellable callback = liftIO $ do
maybeSourceObject <- case sourceObject of
Nothing -> return nullPtr
Just jSourceObject -> do
jSourceObject' <- unsafeManagedPtrCastPtr jSourceObject
return jSourceObject'
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
let callbackData = nullPtr
result <- g_task_new maybeSourceObject maybeCancellable maybeCallback callbackData
checkUnexpectedReturnNULL "taskNew" result
result' <- (wrapObject Task) result
whenJust sourceObject touchManagedPtr
whenJust cancellable touchManagedPtr
return result'
#if ENABLE_OVERLOADING
#endif
-- method Task::get_cancellable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Cancellable"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_cancellable" g_task_get_cancellable ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO (Ptr Gio.Cancellable.Cancellable)
{- |
Gets /@task@/\'s 'GI.Gio.Objects.Cancellable.Cancellable'
/Since: 2.36/
-}
taskGetCancellable ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m Gio.Cancellable.Cancellable
{- ^ __Returns:__ /@task@/\'s 'GI.Gio.Objects.Cancellable.Cancellable' -}
taskGetCancellable task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_cancellable task'
checkUnexpectedReturnNULL "taskGetCancellable" result
result' <- (newObject Gio.Cancellable.Cancellable) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskGetCancellableMethodInfo
instance (signature ~ (m Gio.Cancellable.Cancellable), MonadIO m, IsTask a) => O.MethodInfo TaskGetCancellableMethodInfo a signature where
overloadedMethod _ = taskGetCancellable
#endif
-- method Task::get_check_cancellable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_check_cancellable" g_task_get_check_cancellable ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CInt
{- |
Gets /@task@/\'s check-cancellable flag. See
'GI.Gio.Objects.Task.taskSetCheckCancellable' for more details.
/Since: 2.36/
-}
taskGetCheckCancellable ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> m Bool
taskGetCheckCancellable task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_check_cancellable task'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskGetCheckCancellableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskGetCheckCancellableMethodInfo a signature where
overloadedMethod _ = taskGetCheckCancellable
#endif
-- method Task::get_completed
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_completed" g_task_get_completed ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CInt
{- |
Gets the value of 'GI.Gio.Objects.Task.Task':@/completed/@. This changes from 'False' to 'True' after
the task’s callback is invoked, and will return 'False' if called from inside
the callback.
/Since: 2.44/
-}
taskGetCompleted ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> m Bool
{- ^ __Returns:__ 'True' if the task has completed, 'False' otherwise. -}
taskGetCompleted task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_completed task'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskGetCompletedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskGetCompletedMethodInfo a signature where
overloadedMethod _ = taskGetCompleted
#endif
-- method Task::get_context
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "MainContext"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_context" g_task_get_context ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO (Ptr GLib.MainContext.MainContext)
{- |
Gets the 'GI.GLib.Structs.MainContext.MainContext' that /@task@/ will return its result in (that
is, the context that was the
[thread-default main context][g-main-context-push-thread-default]
at the point when /@task@/ was created).
This will always return a non-'Nothing' value, even if the task\'s
context is the default 'GI.GLib.Structs.MainContext.MainContext'.
/Since: 2.36/
-}
taskGetContext ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m GLib.MainContext.MainContext
{- ^ __Returns:__ /@task@/\'s 'GI.GLib.Structs.MainContext.MainContext' -}
taskGetContext task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_context task'
checkUnexpectedReturnNULL "taskGetContext" result
result' <- (newBoxed GLib.MainContext.MainContext) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskGetContextMethodInfo
instance (signature ~ (m GLib.MainContext.MainContext), MonadIO m, IsTask a) => O.MethodInfo TaskGetContextMethodInfo a signature where
overloadedMethod _ = taskGetContext
#endif
-- method Task::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_name" g_task_get_name ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CString
{- |
Gets /@task@/’s name. See 'GI.Gio.Objects.Task.taskSetName'.
/Since: 2.60/
-}
taskGetName ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m (Maybe T.Text)
{- ^ __Returns:__ /@task@/’s name, or 'Nothing' -}
taskGetName task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_name task'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- cstringToText result'
return result''
touchManagedPtr task
return maybeResult
#if ENABLE_OVERLOADING
data TaskGetNameMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsTask a) => O.MethodInfo TaskGetNameMethodInfo a signature where
overloadedMethod _ = taskGetName
#endif
-- method Task::get_priority
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_priority" g_task_get_priority ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO Int32
{- |
Gets /@task@/\'s priority
/Since: 2.36/
-}
taskGetPriority ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m Int32
{- ^ __Returns:__ /@task@/\'s priority -}
taskGetPriority task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_priority task'
touchManagedPtr task
return result
#if ENABLE_OVERLOADING
data TaskGetPriorityMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsTask a) => O.MethodInfo TaskGetPriorityMethodInfo a signature where
overloadedMethod _ = taskGetPriority
#endif
-- method Task::get_return_on_cancel
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_return_on_cancel" g_task_get_return_on_cancel ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CInt
{- |
Gets /@task@/\'s return-on-cancel flag. See
'GI.Gio.Objects.Task.taskSetReturnOnCancel' for more details.
/Since: 2.36/
-}
taskGetReturnOnCancel ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> m Bool
taskGetReturnOnCancel task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_return_on_cancel task'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskGetReturnOnCancelMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskGetReturnOnCancelMethodInfo a signature where
overloadedMethod _ = taskGetReturnOnCancel
#endif
-- method Task::get_source_object
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GObject", name = "Object"}))
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_source_object" g_task_get_source_object ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO (Ptr GObject.Object.Object)
{- |
Gets the source object from /@task@/. Like
'GI.Gio.Interfaces.AsyncResult.asyncResultGetSourceObject', but does not ref the object.
/Since: 2.36/
-}
taskGetSourceObject ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m (Maybe GObject.Object.Object)
{- ^ __Returns:__ /@task@/\'s source object, or 'Nothing' -}
taskGetSourceObject task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_source_object task'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (newObject GObject.Object.Object) result'
return result''
touchManagedPtr task
return maybeResult
#if ENABLE_OVERLOADING
data TaskGetSourceObjectMethodInfo
instance (signature ~ (m (Maybe GObject.Object.Object)), MonadIO m, IsTask a) => O.MethodInfo TaskGetSourceObjectMethodInfo a signature where
overloadedMethod _ = taskGetSourceObject
#endif
-- method Task::get_source_tag
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_source_tag" g_task_get_source_tag ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO (Ptr ())
{- |
Gets /@task@/\'s source tag. See 'GI.Gio.Objects.Task.taskSetSourceTag'.
/Since: 2.36/
-}
taskGetSourceTag ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m (Ptr ())
{- ^ __Returns:__ /@task@/\'s source tag -}
taskGetSourceTag task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_source_tag task'
touchManagedPtr task
return result
#if ENABLE_OVERLOADING
data TaskGetSourceTagMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m, IsTask a) => O.MethodInfo TaskGetSourceTagMethodInfo a signature where
overloadedMethod _ = taskGetSourceTag
#endif
-- method Task::get_task_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_get_task_data" g_task_get_task_data ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO (Ptr ())
{- |
Gets /@task@/\'s @task_data@.
/Since: 2.36/
-}
taskGetTaskData ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m (Ptr ())
{- ^ __Returns:__ /@task@/\'s @task_data@. -}
taskGetTaskData task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_get_task_data task'
touchManagedPtr task
return result
#if ENABLE_OVERLOADING
data TaskGetTaskDataMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m, IsTask a) => O.MethodInfo TaskGetTaskDataMethodInfo a signature where
overloadedMethod _ = taskGetTaskData
#endif
-- method Task::had_error
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_had_error" g_task_had_error ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CInt
{- |
Tests if /@task@/ resulted in an error.
/Since: 2.36/
-}
taskHadError ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> m Bool
{- ^ __Returns:__ 'True' if the task resulted in an error, 'False' otherwise. -}
taskHadError task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_had_error task'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskHadErrorMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskHadErrorMethodInfo a signature where
overloadedMethod _ = taskHadError
#endif
-- method Task::propagate_boolean
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False
foreign import ccall "g_task_propagate_boolean" g_task_propagate_boolean ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr (Ptr GError) -> -- error
IO CInt
{- |
Gets the result of /@task@/ as a 'Bool'.
If the task resulted in an error, or was cancelled, then this will
instead return 'False' and set /@error@/.
Since this method transfers ownership of the return value (or
error) to the caller, you may only call it once.
/Since: 2.36/
-}
taskPropagateBoolean ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> m ()
{- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
taskPropagateBoolean task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
onException (do
_ <- propagateGError $ g_task_propagate_boolean task'
touchManagedPtr task
return ()
) (do
return ()
)
#if ENABLE_OVERLOADING
data TaskPropagateBooleanMethodInfo
instance (signature ~ (m ()), MonadIO m, IsTask a) => O.MethodInfo TaskPropagateBooleanMethodInfo a signature where
overloadedMethod _ = taskPropagateBoolean
#endif
-- method Task::propagate_int
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : True
-- Skip return : False
foreign import ccall "g_task_propagate_int" g_task_propagate_int ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr (Ptr GError) -> -- error
IO Int64
{- |
Gets the result of /@task@/ as an integer (@/gssize/@).
If the task resulted in an error, or was cancelled, then this will
instead return -1 and set /@error@/.
Since this method transfers ownership of the return value (or
error) to the caller, you may only call it once.
/Since: 2.36/
-}
taskPropagateInt ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> m Int64
{- ^ __Returns:__ the task result, or -1 on error /(Can throw 'Data.GI.Base.GError.GError')/ -}
taskPropagateInt task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
onException (do
result <- propagateGError $ g_task_propagate_int task'
touchManagedPtr task
return result
) (do
return ()
)
#if ENABLE_OVERLOADING
data TaskPropagateIntMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsTask a) => O.MethodInfo TaskPropagateIntMethodInfo a signature where
overloadedMethod _ = taskPropagateInt
#endif
-- method Task::propagate_pointer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : True
-- Skip return : False
foreign import ccall "g_task_propagate_pointer" g_task_propagate_pointer ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr (Ptr GError) -> -- error
IO (Ptr ())
{- |
Gets the result of /@task@/ as a pointer, and transfers ownership
of that value to the caller.
If the task resulted in an error, or was cancelled, then this will
instead return 'Nothing' and set /@error@/.
Since this method transfers ownership of the return value (or
error) to the caller, you may only call it once.
/Since: 2.36/
-}
taskPropagatePointer ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m (Ptr ())
{- ^ __Returns:__ the task result, or 'Nothing' on error /(Can throw 'Data.GI.Base.GError.GError')/ -}
taskPropagatePointer task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
onException (do
result <- propagateGError $ g_task_propagate_pointer task'
touchManagedPtr task
return result
) (do
return ()
)
#if ENABLE_OVERLOADING
data TaskPropagatePointerMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m, IsTask a) => O.MethodInfo TaskPropagatePointerMethodInfo a signature where
overloadedMethod _ = taskPropagatePointer
#endif
-- method Task::return_boolean
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #gboolean result of a task function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_return_boolean" g_task_return_boolean ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
CInt -> -- result : TBasicType TBoolean
IO ()
{- |
Sets /@task@/\'s result to /@result@/ and completes the task (see
'GI.Gio.Objects.Task.taskReturnPointer' for more discussion of exactly what this
means).
/Since: 2.36/
-}
taskReturnBoolean ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> Bool
{- ^ /@result@/: the 'Bool' result of a task function. -}
-> m ()
taskReturnBoolean task result_ = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
let result_' = (fromIntegral . fromEnum) result_
g_task_return_boolean task' result_'
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskReturnBooleanMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskReturnBooleanMethodInfo a signature where
overloadedMethod _ = taskReturnBoolean
#endif
-- method Task::return_error
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "error", argType = TError, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GError result of a task function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_return_error" g_task_return_error ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr GError -> -- error : TError
IO ()
{- |
Sets /@task@/\'s result to /@error@/ (which /@task@/ assumes ownership of)
and completes the task (see 'GI.Gio.Objects.Task.taskReturnPointer' for more
discussion of exactly what this means).
Note that since the task takes ownership of /@error@/, and since the
task may be completed before returning from 'GI.Gio.Objects.Task.taskReturnError',
you cannot assume that /@error@/ is still valid after calling this.
Call 'GI.GLib.Structs.Error.errorCopy' on the error if you need to keep a local copy
as well.
See also @/g_task_return_new_error()/@.
/Since: 2.36/
-}
taskReturnError ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> GError
{- ^ /@error@/: the 'GError' result of a task function. -}
-> m ()
taskReturnError task error_ = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
error_' <- B.ManagedPtr.disownBoxed error_
g_task_return_error task' error_'
touchManagedPtr task
touchManagedPtr error_
return ()
#if ENABLE_OVERLOADING
data TaskReturnErrorMethodInfo
instance (signature ~ (GError -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskReturnErrorMethodInfo a signature where
overloadedMethod _ = taskReturnError
#endif
-- method Task::return_error_if_cancelled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_return_error_if_cancelled" g_task_return_error_if_cancelled ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
IO CInt
{- |
Checks if /@task@/\'s 'GI.Gio.Objects.Cancellable.Cancellable' has been cancelled, and if so, sets
/@task@/\'s error accordingly and completes the task (see
'GI.Gio.Objects.Task.taskReturnPointer' for more discussion of exactly what this
means).
/Since: 2.36/
-}
taskReturnErrorIfCancelled ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> m Bool
{- ^ __Returns:__ 'True' if /@task@/ has been cancelled, 'False' if not -}
taskReturnErrorIfCancelled task = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
result <- g_task_return_error_if_cancelled task'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskReturnErrorIfCancelledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskReturnErrorIfCancelledMethodInfo a signature where
overloadedMethod _ = taskReturnErrorIfCancelled
#endif
-- method Task::return_int
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the integer (#gssize) result of a task function.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_return_int" g_task_return_int ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Int64 -> -- result : TBasicType TInt64
IO ()
{- |
Sets /@task@/\'s result to /@result@/ and completes the task (see
'GI.Gio.Objects.Task.taskReturnPointer' for more discussion of exactly what this
means).
/Since: 2.36/
-}
taskReturnInt ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task'. -}
-> Int64
{- ^ /@result@/: the integer (@/gssize/@) result of a task function. -}
-> m ()
taskReturnInt task result_ = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
g_task_return_int task' result_
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskReturnIntMethodInfo
instance (signature ~ (Int64 -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskReturnIntMethodInfo a signature where
overloadedMethod _ = taskReturnInt
#endif
-- method Task::return_pointer
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the pointer result of a task\n function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "result_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GDestroyNotify function.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_return_pointer" g_task_return_pointer ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr () -> -- result : TBasicType TPtr
FunPtr GLib.Callbacks.C_DestroyNotify -> -- result_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
IO ()
{- |
Sets /@task@/\'s result to /@result@/ and completes the task. If /@result@/
is not 'Nothing', then /@resultDestroy@/ will be used to free /@result@/ if
the caller does not take ownership of it with
'GI.Gio.Objects.Task.taskPropagatePointer'.
\"Completes the task\" means that for an ordinary asynchronous task
it will either invoke the task\'s callback, or else queue that
callback to be invoked in the proper 'GI.GLib.Structs.MainContext.MainContext', or in the next
iteration of the current 'GI.GLib.Structs.MainContext.MainContext'. For a task run via
@/g_task_run_in_thread()/@ or @/g_task_run_in_thread_sync()/@, calling this
method will save /@result@/ to be returned to the caller later, but
the task will not actually be completed until the 'GI.Gio.Callbacks.TaskThreadFunc'
exits.
Note that since the task may be completed before returning from
'GI.Gio.Objects.Task.taskReturnPointer', you cannot assume that /@result@/ is still
valid after calling this, unless you are still holding another
reference on it.
/Since: 2.36/
-}
taskReturnPointer ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> Ptr ()
{- ^ /@result@/: the pointer result of a task
function -}
-> Maybe (GLib.Callbacks.DestroyNotify)
{- ^ /@resultDestroy@/: a 'GI.GLib.Callbacks.DestroyNotify' function. -}
-> m ()
taskReturnPointer task result_ resultDestroy = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
maybeResultDestroy <- case resultDestroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jResultDestroy -> do
ptrresultDestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
jResultDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrresultDestroy) jResultDestroy)
poke ptrresultDestroy jResultDestroy'
return jResultDestroy'
g_task_return_pointer task' result_ maybeResultDestroy
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskReturnPointerMethodInfo
instance (signature ~ (Ptr () -> Maybe (GLib.Callbacks.DestroyNotify) -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskReturnPointerMethodInfo a signature where
overloadedMethod _ = taskReturnPointer
#endif
-- method Task::set_check_cancellable
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "check_cancellable", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether #GTask will check the state of\n its #GCancellable for you.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_check_cancellable" g_task_set_check_cancellable ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
CInt -> -- check_cancellable : TBasicType TBoolean
IO ()
{- |
Sets or clears /@task@/\'s check-cancellable flag. If this is 'True'
(the default), then 'GI.Gio.Objects.Task.taskPropagatePointer', etc, and
'GI.Gio.Objects.Task.taskHadError' will check the task\'s 'GI.Gio.Objects.Cancellable.Cancellable' first, and
if it has been cancelled, then they will consider the task to have
returned an \"Operation was cancelled\" error
('GI.Gio.Enums.IOErrorEnumCancelled'), regardless of any other error or return
value the task may have had.
If /@checkCancellable@/ is 'False', then the 'GI.Gio.Objects.Task.Task' will not check the
cancellable itself, and it is up to /@task@/\'s owner to do this (eg,
via 'GI.Gio.Objects.Task.taskReturnErrorIfCancelled').
If you are using 'GI.Gio.Objects.Task.taskSetReturnOnCancel' as well, then
you must leave check-cancellable set 'True'.
/Since: 2.36/
-}
taskSetCheckCancellable ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> Bool
{- ^ /@checkCancellable@/: whether 'GI.Gio.Objects.Task.Task' will check the state of
its 'GI.Gio.Objects.Cancellable.Cancellable' for you. -}
-> m ()
taskSetCheckCancellable task checkCancellable = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
let checkCancellable' = (fromIntegral . fromEnum) checkCancellable
g_task_set_check_cancellable task' checkCancellable'
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskSetCheckCancellableMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetCheckCancellableMethodInfo a signature where
overloadedMethod _ = taskSetCheckCancellable
#endif
-- method Task::set_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a human readable name for the task, or %NULL to unset it", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_name" g_task_set_name ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
CString -> -- name : TBasicType TUTF8
IO ()
{- |
Sets /@task@/’s name, used in debugging and profiling. The name defaults to
'Nothing'.
The task name should describe in a human readable way what the task does.
For example, ‘Open file’ or ‘Connect to network host’. It is used to set the
name of the 'GI.GLib.Structs.Source.Source' used for idle completion of the task.
This function may only be called before the /@task@/ is first used in a thread
other than the one it was constructed in.
/Since: 2.60/
-}
taskSetName ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: a 'GI.Gio.Objects.Task.Task' -}
-> Maybe (T.Text)
{- ^ /@name@/: a human readable name for the task, or 'Nothing' to unset it -}
-> m ()
taskSetName task name = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
maybeName <- case name of
Nothing -> return nullPtr
Just jName -> do
jName' <- textToCString jName
return jName'
g_task_set_name task' maybeName
touchManagedPtr task
freeMem maybeName
return ()
#if ENABLE_OVERLOADING
data TaskSetNameMethodInfo
instance (signature ~ (Maybe (T.Text) -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetNameMethodInfo a signature where
overloadedMethod _ = taskSetName
#endif
-- method Task::set_priority
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_priority" g_task_set_priority ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Int32 -> -- priority : TBasicType TInt
IO ()
{- |
Sets /@task@/\'s priority. If you do not call this, it will default to
'GI.GLib.Constants.PRIORITY_DEFAULT'.
This will affect the priority of @/GSources/@ created with
@/g_task_attach_source()/@ and the scheduling of tasks run in threads,
and can also be explicitly retrieved later via
'GI.Gio.Objects.Task.taskGetPriority'.
/Since: 2.36/
-}
taskSetPriority ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> Int32
{- ^ /@priority@/: the [priority][io-priority] of the request -}
-> m ()
taskSetPriority task priority = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
g_task_set_priority task' priority
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskSetPriorityMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetPriorityMethodInfo a signature where
overloadedMethod _ = taskSetPriority
#endif
-- method Task::set_return_on_cancel
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "return_on_cancel", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the task returns automatically when\n it is cancelled.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_return_on_cancel" g_task_set_return_on_cancel ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
CInt -> -- return_on_cancel : TBasicType TBoolean
IO CInt
{- |
Sets or clears /@task@/\'s return-on-cancel flag. This is only
meaningful for tasks run via @/g_task_run_in_thread()/@ or
@/g_task_run_in_thread_sync()/@.
If /@returnOnCancel@/ is 'True', then cancelling /@task@/\'s
'GI.Gio.Objects.Cancellable.Cancellable' will immediately cause it to return, as though the
task\'s 'GI.Gio.Callbacks.TaskThreadFunc' had called
'GI.Gio.Objects.Task.taskReturnErrorIfCancelled' and then returned.
This allows you to create a cancellable wrapper around an
uninterruptable function. The 'GI.Gio.Callbacks.TaskThreadFunc' just needs to be
careful that it does not modify any externally-visible state after
it has been cancelled. To do that, the thread should call
'GI.Gio.Objects.Task.taskSetReturnOnCancel' again to (atomically) set
return-on-cancel 'False' before making externally-visible changes;
if the task gets cancelled before the return-on-cancel flag could
be changed, 'GI.Gio.Objects.Task.taskSetReturnOnCancel' will indicate this by
returning 'False'.
You can disable and re-enable this flag multiple times if you wish.
If the task\'s 'GI.Gio.Objects.Cancellable.Cancellable' is cancelled while return-on-cancel is
'False', then calling 'GI.Gio.Objects.Task.taskSetReturnOnCancel' to set it 'True'
again will cause the task to be cancelled at that point.
If the task\'s 'GI.Gio.Objects.Cancellable.Cancellable' is already cancelled before you call
@/g_task_run_in_thread()/@\/@/g_task_run_in_thread_sync()/@, then the
'GI.Gio.Callbacks.TaskThreadFunc' will still be run (for consistency), but the task
will also be completed right away.
/Since: 2.36/
-}
taskSetReturnOnCancel ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> Bool
{- ^ /@returnOnCancel@/: whether the task returns automatically when
it is cancelled. -}
-> m Bool
{- ^ __Returns:__ 'True' if /@task@/\'s return-on-cancel flag was changed to
match /@returnOnCancel@/. 'False' if /@task@/ has already been
cancelled. -}
taskSetReturnOnCancel task returnOnCancel = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
let returnOnCancel' = (fromIntegral . fromEnum) returnOnCancel
result <- g_task_set_return_on_cancel task' returnOnCancel'
let result' = (/= 0) result
touchManagedPtr task
return result'
#if ENABLE_OVERLOADING
data TaskSetReturnOnCancelMethodInfo
instance (signature ~ (Bool -> m Bool), MonadIO m, IsTask a) => O.MethodInfo TaskSetReturnOnCancelMethodInfo a signature where
overloadedMethod _ = taskSetReturnOnCancel
#endif
-- method Task::set_source_tag
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_tag", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an opaque pointer indicating the source of this task", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_source_tag" g_task_set_source_tag ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr () -> -- source_tag : TBasicType TPtr
IO ()
{- |
Sets /@task@/\'s source tag. You can use this to tag a task return
value with a particular pointer (usually a pointer to the function
doing the tagging) and then later check it using
'GI.Gio.Objects.Task.taskGetSourceTag' (or 'GI.Gio.Interfaces.AsyncResult.asyncResultIsTagged') in the
task\'s \"finish\" function, to figure out if the response came from a
particular place.
/Since: 2.36/
-}
taskSetSourceTag ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> Ptr ()
{- ^ /@sourceTag@/: an opaque pointer indicating the source of this task -}
-> m ()
taskSetSourceTag task sourceTag = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
g_task_set_source_tag task' sourceTag
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskSetSourceTagMethodInfo
instance (signature ~ (Ptr () -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetSourceTagMethodInfo a signature where
overloadedMethod _ = taskSetSourceTag
#endif
-- method Task::set_task_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "task", argType = TInterface (Name {namespace = "Gio", name = "Task"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "task_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "task-specific data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "task_data_destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "#GDestroyNotify for @task_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_set_task_data" g_task_set_task_data ::
Ptr Task -> -- task : TInterface (Name {namespace = "Gio", name = "Task"})
Ptr () -> -- task_data : TBasicType TPtr
FunPtr GLib.Callbacks.C_DestroyNotify -> -- task_data_destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
IO ()
{- |
Sets /@task@/\'s task data (freeing the existing task data, if any).
/Since: 2.36/
-}
taskSetTaskData ::
(B.CallStack.HasCallStack, MonadIO m, IsTask a) =>
a
{- ^ /@task@/: the 'GI.Gio.Objects.Task.Task' -}
-> Ptr ()
{- ^ /@taskData@/: task-specific data -}
-> Maybe (GLib.Callbacks.DestroyNotify)
{- ^ /@taskDataDestroy@/: 'GI.GLib.Callbacks.DestroyNotify' for /@taskData@/ -}
-> m ()
taskSetTaskData task taskData taskDataDestroy = liftIO $ do
task' <- unsafeManagedPtrCastPtr task
maybeTaskDataDestroy <- case taskDataDestroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jTaskDataDestroy -> do
ptrtaskDataDestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
jTaskDataDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrtaskDataDestroy) jTaskDataDestroy)
poke ptrtaskDataDestroy jTaskDataDestroy'
return jTaskDataDestroy'
g_task_set_task_data task' taskData maybeTaskDataDestroy
touchManagedPtr task
return ()
#if ENABLE_OVERLOADING
data TaskSetTaskDataMethodInfo
instance (signature ~ (Ptr () -> Maybe (GLib.Callbacks.DestroyNotify) -> m ()), MonadIO m, IsTask a) => O.MethodInfo TaskSetTaskDataMethodInfo a signature where
overloadedMethod _ = taskSetTaskData
#endif
-- method Task::is_valid
-- method type : MemberFunction
-- Args : [Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the source object\n expected to be associated with the task", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "g_task_is_valid" g_task_is_valid ::
Ptr Gio.AsyncResult.AsyncResult -> -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
Ptr GObject.Object.Object -> -- source_object : TInterface (Name {namespace = "GObject", name = "Object"})
IO CInt
{- |
Checks that /@result@/ is a 'GI.Gio.Objects.Task.Task', and that /@sourceObject@/ is its
source object (or that /@sourceObject@/ is 'Nothing' and /@result@/ has no
source object). This can be used in @/g_return_if_fail()/@ checks.
/Since: 2.36/
-}
taskIsValid ::
(B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a, GObject.Object.IsObject b) =>
a
{- ^ /@result@/: A 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
-> Maybe (b)
{- ^ /@sourceObject@/: the source object
expected to be associated with the task -}
-> m Bool
{- ^ __Returns:__ 'True' if /@result@/ and /@sourceObject@/ are valid, 'False'
if not -}
taskIsValid result_ sourceObject = liftIO $ do
result_' <- unsafeManagedPtrCastPtr result_
maybeSourceObject <- case sourceObject of
Nothing -> return nullPtr
Just jSourceObject -> do
jSourceObject' <- unsafeManagedPtrCastPtr jSourceObject
return jSourceObject'
result <- g_task_is_valid result_' maybeSourceObject
let result' = (/= 0) result
touchManagedPtr result_
whenJust sourceObject touchManagedPtr
return result'
#if ENABLE_OVERLOADING
#endif
-- method Task::report_error
-- method type : MemberFunction
-- Args : [Arg {argCName = "source_object", argType = TInterface (Name {namespace = "GObject", name = "Object"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GObject that owns\n this task, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_tag", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an opaque pointer indicating the source of this task", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "error", argType = TError, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "error to report", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "g_task_report_error" g_task_report_error ::
Ptr GObject.Object.Object -> -- source_object : TInterface (Name {namespace = "GObject", name = "Object"})
FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
Ptr () -> -- callback_data : TBasicType TPtr
Ptr () -> -- source_tag : TBasicType TPtr
Ptr GError -> -- error : TError
IO ()
{- |
Creates a 'GI.Gio.Objects.Task.Task' and then immediately calls 'GI.Gio.Objects.Task.taskReturnError'
on it. Use this in the wrapper function of an asynchronous method
when you want to avoid even calling the virtual method. You can
then use 'GI.Gio.Interfaces.AsyncResult.asyncResultIsTagged' in the finish method wrapper to
check if the result there is tagged as having been created by the
wrapper method, and deal with it appropriately if so.
See also @/g_task_report_new_error()/@.
/Since: 2.36/
-}
taskReportError ::
(B.CallStack.HasCallStack, MonadIO m, GObject.Object.IsObject a) =>
Maybe (a)
{- ^ /@sourceObject@/: the 'GI.GObject.Objects.Object.Object' that owns
this task, or 'Nothing'. -}
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
{- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback'. -}
-> Ptr ()
{- ^ /@sourceTag@/: an opaque pointer indicating the source of this task -}
-> GError
{- ^ /@error@/: error to report -}
-> m ()
taskReportError sourceObject callback sourceTag error_ = liftIO $ do
maybeSourceObject <- case sourceObject of
Nothing -> return nullPtr
Just jSourceObject -> do
jSourceObject' <- unsafeManagedPtrCastPtr jSourceObject
return jSourceObject'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
error_' <- B.ManagedPtr.disownBoxed error_
let callbackData = nullPtr
g_task_report_error maybeSourceObject maybeCallback callbackData sourceTag error_'
whenJust sourceObject touchManagedPtr
touchManagedPtr error_
return ()
#if ENABLE_OVERLOADING
#endif