Cancels a job which has not yet been processed. If the job cannot be found, is being processed or has already been processed, then this function returns %FALSE.
This function can be called on already cancelled jobs, and simply returns %TRUE in that case.
the ID of the job, as returned by gda_worker_submit_job()
Request that the worker thread call func
with the data
argument, much like gda_worker_submit_job(),
but waits (starting a #GMainLoop) for a maximum of timeout_ms
miliseconds for func
to be executed.
If this function is called from within worker'
s worker thread, then this function simply calls func
with data
and does not
use context
.
The following cases are possible if this function is not called from within worker'
s worker thread:
func
took less than timeout_ms
miliseconds: the return value is %TRUE and
out_result
contains the result of the func'
s execution, and out_job_id
contains %NULL. Note in this
case that error
may still contain an error code if func'
s execution produced an error. Also note that in this case
any setting defined by gda_worker_set_callback() is not applied (as the result is immediately returned)func
takes more then timeout_ms
miliseconds: the return value is %TRUE and
out_result
is %NULL and out_job_id
contains the ID of the job as if it had been submitted using gda_worker_submit_job().
If out_job_id
is %NULL, and if no setting has been defined using gda_worker_set_callback(), then the job will be discarded
(as if gda_worker_forget_job() had been called).
func
could not be done (some kind of plumbing error for instance): the returned value is %FALSE
and out_result
and out_job_id
are set to %NULL (if they are not %NULL)
Notes:
result_destroy_func
is needed in case out_result
is %NULL (to avoid memory leaks)context
is similar to passing the result of g_main_context_ref_thread_default()
a #GMainContext to execute a main loop in (while waiting), or %NULL
the maximum number of milisecons to wait before returning, or %0 for unlimited wait
a place to store the result, if any, of func'
s execution, or %NULL
a place to store the ID of the job having been submitted, or %NULL
the function to call from the worker thread
a function to destroy data,
or %NULL
Fetch the value returned by execution the job_id
job.
Warning: if an error occurred during the
execution of the requested function within the worker thread, then it will show as error,
while the return value
of this function will be %TRUE.
Note: if there is a result, it will be stored in out_result,
and it's up to the caller to free
the result, the #GdaWorker object will not do it (ownership of the result is transfered to the caller).
the ID of the job, as returned by gda_worker_submit_job()
a place to store the value returned by the execution of the requested function within the worker thread, or %NULL
Forget all about the job with ID job_id
. As opposed to gda_worker_cancel_job(), this function can be used to tell
worker
that whatever happens to the specific job, you are not interrested anymore (i.e. that worker
can
do whatever is possible to simple discard everything related to that job).
the ID of the job, as returned by gda_worker_submit_job()
Get a pointer to worker'
s inner worker thread
Declare a callback function to be called when a job has been processed. If callback
is %NULL, then any previously
effect of this function is removed. If the same function is called with a different callback
value, then the previous one
is simply replaced.
Since this function adds a new source of events to the specified #GMainContext (or the default one if context
is %NULL),
Notes:
worker
internally gets rid of the job, so the jib_id
passed
to callback
does not actually designate a known job ID, and so calling gda_worker_fetch_job_result() for that
job ID will failcallback
(worker
does not do it)context
is similar to passing the result of g_main_context_ref_thread_default()
a #GMainContext, or %NULL
the function to call when a job submitted from within the calling thread using gda_worker_submit_job() has finished being processed.
Request that the worker thread call func
with the data
argument.
Notes:
data_destroy_func
is not %NULL, then it will be called to destroy data
when the job is removed,
which can occur within the context of the worker thread, or within the context of any thread using worker
.result_destroy_func
is not %NULL, then it will be called to destroy the result produced by func
.
Similarly to data_destroy_func,
if it is not %NULL (and if there is a non %NULL result), then that function can be
called in the context of any thread.func
from the worker thread.callback_context
is similar to passing the result of g_main_context_ref_thread_default()
a #GMainContext, or %NULL (ignored if no setting has been defined with gda_worker_set_callback())
the function to call from the worker thread
a function to destroy data,
or %NULL
Tells if the thread from which this function is called is worker'
s worker thread.
Decreases worker'
s reference count. When reference count reaches %0, then the
object is destroyed, note that in this case this function only returns when the
worker thread actually has terminated, which can take some time if it's busy.
If worker
is %NULL, then nothing happens.
Request that the worker thread call func
with the data
argument, much like gda_worker_submit_job(),
but waits (blocks) until func
has been executed.
Note: it's up to the caller to free the result, the #GdaWorker object will not do it (ownership of the result is transfered to the caller).
the function to call from the worker thread
This function creates a new #GdaWorker, or reuses the one at location
. Specifically:
location
is %NULL, then a new #GdaWorker is created. In this case if allow_destroy
is %FALSE, then the returned
#GdaWorker's reference count is 2, thus preventing it form ever being destroyed (unless gda_worker_unref() is called somewhere else)location
is not %NULL, the the #GdaWorker it points to is returned, its reference count increased by 1
When the returned #GdaWorker's reference count reaches 0, then it is destroyed, and *location
is set to %NULL.
In any case, the returned value is the same as *location
.
a place to store and test for existence, not %NULL
defines if the created GdaWorker
(see case 1 below) will allow its reference to drop to 0 and be destroyed
Creates a new #GdaWorker object.