![]() |
![]() |
![]() |
UDisks Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
UDisksThreadedJob; gboolean (*UDisksThreadedJobFunc) (UDisksThreadedJob *job
,GCancellable *cancellable
,gpointer user_data
,GError **error
); UDisksThreadedJob * udisks_threaded_job_new (UDisksThreadedJobFunc job_func
,gpointer user_data
,GDestroyNotify user_data_free_func
,UDisksDaemon *daemon
,GCancellable *cancellable
); void udisks_threaded_job_start (UDisksThreadedJob *job
); gpointer udisks_threaded_job_get_user_data (UDisksThreadedJob *job
);
GObject +----GDBusInterfaceSkeleton +----UDisksJobSkeleton +----UDisksBaseJob +----UDisksThreadedJob
"job-func" gpointer : Read / Write / Construct Only "user-data" gpointer : Read / Write / Construct Only "user-data-free-func" gpointer : Read / Write / Construct Only
This type provides an implementation of the UDisksJob interface for jobs that run in a thread.
typedef struct _UDisksThreadedJob UDisksThreadedJob;
The UDisksThreadedJob structure contains only private data and should only be accessed using the provided API.
gboolean (*UDisksThreadedJobFunc) (UDisksThreadedJob *job
,GCancellable *cancellable
,gpointer user_data
,GError **error
);
Job function that runs in a separate thread.
Long-running jobs should periodically check cancellable
to see if
they have been cancelled.
|
A UDisksThreadedJob. |
|
A GCancellable (never NULL ). |
|
User data passed when creating job . |
|
Return location for error (never NULL ). |
Returns : |
TRUE if the job succeeded, FALSE if error is set. |
UDisksThreadedJob * udisks_threaded_job_new (UDisksThreadedJobFunc job_func
,gpointer user_data
,GDestroyNotify user_data_free_func
,UDisksDaemon *daemon
,GCancellable *cancellable
);
Creates a new UDisksThreadedJob instance.
The job is not started automatically! Use udisks_threaded_job_start()
to
start the job after "threaded-job-completed" or
"completed" signals are connected (to get notified when the job is
done). This is to prevent a race condition with the job_func
finishing
before the signals are connected in which case the signal handlers are never
triggered.
|
The function to run in another thread. |
|
User data to pass to job_func . |
|
Function to free user_data with or NULL . |
|
A UDisksDaemon. |
|
A GCancellable or NULL . |
Returns : |
A new UDisksThreadedJob. Free with g_object_unref() . |
void udisks_threaded_job_start (UDisksThreadedJob *job
);
Start the job
. Connect to the "threaded-job-completed" or
"completed" signals to get notified when the job is done.
*/ void udisks_threaded_job_start (UDisksThreadedJob *job) { GTask *task;
task = g_task_new (NULL, udisks_base_job_get_cancellable (UDISKS_BASE_JOB (job)), NULL, NULL);
g_task_set_task_data (task, job, NULL); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, run_task_job); g_object_unref (task); }
/**
udisks_threaded_job_get_user_data:
job
: A UDisksThreadedJob.
Gets the user_data
parameter that job
was constructed with.
|
the job to start |
Returns : |
A gpointer owned by job . |
gpointer udisks_threaded_job_get_user_data (UDisksThreadedJob *job
);
"job-func"
property "job-func" gpointer : Read / Write / Construct Only
The UDisksThreadedJobFunc to use.
"user-data"
property "user-data" gpointer : Read / Write / Construct Only
User data for the UDisksThreadedJobFunc.
"user-data-free-func"
property "user-data-free-func" gpointer : Read / Write / Construct Only
Free function for user data for the UDisksThreadedJobFunc.
"threaded-job-completed"
signalgboolean user_function (UDisksThreadedJob *job,
gboolean result,
GError *error,
gpointer user_data) : Run Last
Emitted when the threaded job is complete.
The default implementation simply emits the "completed"
signal with success
set to TRUE
if, and only if, error
is
NULL
. Otherwise, message
on that signal is set to a string
describing error
. You can avoid the default implementation by
returning TRUE
from your signal handler.
This signal is emitted in the
thread-default main loop
of the thread that job
was created in.
|
The UDisksThreadedJob emitting the signal. |
|
The gboolean returned by the UDisksThreadedJobFunc. |
|
The GError set by the UDisksThreadedJobFunc. |
|
user data set when the signal handler was connected. |
Returns : |
TRUE if the signal was handled, FALSE to let other
handlers run. |