set_callback


Description:

[ Version ( since = "6.0" ) ]
public bool set_callback (MainContext? context, WorkerCallback? callback) throws Error

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 MainContext (or the default one if context is null),

Notes: <itemizedlist> <listitem><para>before calling this function, this internally gets rid of the job, so the jib_id passed to callback does not actually designate a known job ID, and so calling fetch_job_result for that job ID will fail</para>< /listitem> <listitem><para>the job's result, if any, has to be freed by callback ( this does not do it)</para></listitem> <listitem><para>any call to this function will only be honored for the jobs submitted _after_ calling it, the ones submitted before are not affected</para></listitem> <listitem>< para>passing null for context is similar to passing the result of ref_thread_default</para></listitem> </itemizedlist>

Parameters:

this

a Worker object

context

a MainContext, or null

callback

the function to call when a job submitted from within the calling thread using submit_job has finished being processed.

user_data

argument passed to callback

Returns:

true if no error occurred.




2022 vala-language.org