Gjsify LogoGjsify Logo

Hierarchy

  • Worker

Index

Constructors

Properties

name: string

Methods

  • cancelJob(jobId: number): boolean
  • 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.

    Parameters

    • jobId: number

      the ID of the job, as returned by gda_worker_submit_job()

    Returns boolean

  • 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: the call to 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) The call to 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). The call to 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) passing %NULL for context is similar to passing the result of g_main_context_ref_thread_default()

    Parameters

    • context: MainContext

      a #GMainContext to execute a main loop in (while waiting), or %NULL

    • timeoutMs: number

      the maximum number of milisecons to wait before returning, or %0 for unlimited wait

    • outResult: object

      a place to store the result, if any, of func's execution, or %NULL

    • outJobId: number

      a place to store the ID of the job having been submitted, or %NULL

    • func: WorkerFunc

      the function to call from the worker thread

    • dataDestroyFunc: GLib.DestroyNotify

      a function to destroy data, or %NULL

    Returns boolean

  • fetchJobResult(jobId: number, outResult: object): boolean
  • 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).

    Parameters

    • jobId: number

      the ID of the job, as returned by gda_worker_submit_job()

    • outResult: object

      a place to store the value returned by the execution of the requested function within the worker thread, or %NULL

    Returns boolean

  • forgetJob(jobId: number): void
  • 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).

    Parameters

    • jobId: number

      the ID of the job, as returned by gda_worker_submit_job()

    Returns void

  • 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: before calling this function, 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 fail the job's result, if any, has to be freed by callback (worker does not do it) any call to this function will only be honored for the jobs submitted after calling it, the ones submitted before are not affected passing %NULL for context is similar to passing the result of g_main_context_ref_thread_default()

    Parameters

    • context: MainContext

      a #GMainContext, or %NULL

    • callback: WorkerCallback

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

    Returns boolean

  • Request that the worker thread call func with the data argument.

    Notes: if 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. if 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. the error here can only report failures while executing gda_worker_submit_job(), not any error which may occur while executing func from the worker thread. when this function returns, the job may already have been completed, so you should not assume that the job is in any specific state. passing %NULL for callback_context is similar to passing the result of g_main_context_ref_thread_default()

    Parameters

    • callbackContext: MainContext

      a #GMainContext, or %NULL (ignored if no setting has been defined with gda_worker_set_callback())

    • func: WorkerFunc

      the function to call from the worker thread

    • dataDestroyFunc: GLib.DestroyNotify

      a function to destroy data, or %NULL

    Returns number

  • threadIsWorker(): boolean
  • Tells if the thread from which this function is called is worker's worker thread.

    Returns boolean

  • unref(): void
  • 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.

    Returns void

  • 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).

    Parameters

    • func: WorkerFunc

      the function to call from the worker thread

    Returns object

  • errorQuark(): number
  • This function creates a new #GdaWorker, or reuses the one at location. Specifically: if *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) if *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.

    Parameters

    • location: Gda.Worker

      a place to store and test for existence, not %NULL

    • allowDestroy: boolean

      defines if the created GdaWorker (see case 1 below) will allow its reference to drop to 0 and be destroyed

    Returns Gda.Worker

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method