VLC  4.0.0-dev
Data Structures | Functions
background_worker.h File Reference

Go to the source code of this file.

Data Structures

struct  background_worker_config


struct background_workerbackground_worker_New (void *owner, struct background_worker_config *config)
 Create a background-worker. More...
void background_worker_RequestProbe (struct background_worker *worker)
 Request the background-worker to probe the current task. More...
int background_worker_Push (struct background_worker *worker, void *entity, void *id, int timeout)
 Push an entity into the background-worker. More...
void background_worker_Cancel (struct background_worker *worker, void *id)
 Remove entities from the background-worker. More...
void background_worker_Delete (struct background_worker *worker)
 Delete a background-worker. More...

Function Documentation

◆ background_worker_Cancel()

void background_worker_Cancel ( struct background_worker worker,
void *  id 

Remove entities from the background-worker.

This function is used to remove processing of a certain entity given its associated id, or to remove all queued (including currently running) entities.

if the id passed refers to an entity that is currently being processed, the call will block until the task has been terminated.
workerthe background-worker
idNULL if every entity shall be removed, and the currently running task (if any) shall be cancelled.

References BackgroundWorkerCancelLocked(), background_worker::lock, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by input_preparser_Cancel(), input_preparser_Deactivate(), and vlc_thumbnailer_Cancel().

◆ background_worker_Delete()

void background_worker_Delete ( struct background_worker worker)

Delete a background-worker.

This function will destroy a background-worker created through background_worker_New. It will effectively stop the currently running task, if any, and empty the queue of pending entities.

If there is a currently running task, the function will block until it has been stopped.
workerthe background-worker

References background_worker_Destroy(), BackgroundWorkerCancelLocked(), background_worker::closing, background_worker::lock, background_worker::nothreads_wait, background_worker::nthreads, background_worker::queue_wait, vlc_cond_broadcast(), vlc_cond_wait(), vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by input_fetcher_Delete(), input_fetcher_New(), input_preparser_Delete(), and vlc_thumbnailer_Release().

◆ background_worker_New()

struct background_worker* background_worker_New ( void *  owner,
struct background_worker_config config 

Create a background-worker.

This function creates a new background-worker using the passed configuration.

all members of config shall have been set by the caller.
the returned resource must be destroyed using background_worker_Delete on success.
ownerthe owner of the background-worker
configthe background-worker's configuration
a pointer-to the created background-worker on success, NULL on failure.

References background_worker_Create().

Referenced by input_preparser_New(), vlc_thumbnailer_Create(), and WorkerInit().

◆ background_worker_Push()

int background_worker_Push ( struct background_worker worker,
void *  entity,
void *  id,
int  timeout 

Push an entity into the background-worker.

This function is used to push an entity into the queue of pending work. The entities will be processed in the order in which they are received (in terms of the order of invocations in a single-threaded environment).

workerthe background-worker
entitythe entity which is to be queued
ida value suitable for identifying the entity, or NULL
timeoutthe timeout of the entity in milliseconds, 0 denotes no timeout, a negative value will use the default timeout associated with the background-worker.
VLC_SUCCESS if the entity was successfully queued, an error-code on failure.

References background_worker::conf, background_worker::lock, background_worker_config::max_threads, background_worker::nthreads, QueuePush(), SpawnThread(), task_Create(), background_worker::uncompleted, unlikely, VLC_ENOMEM, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_SUCCESS.

Referenced by input_fetcher_Push(), input_preparser_Push(), SearchByScope(), SearchLocal(), and thumbnailer_RequestCommon().

◆ background_worker_RequestProbe()

void background_worker_RequestProbe ( struct background_worker worker)

Request the background-worker to probe the current task.

This function is used to signal the background-worker that it should do another probe to see whether the current task is still alive.

Note that the function will not wait for the probing to finish, it will simply ask the background worker to recheck it as soon as possible.
workerthe background-worker

References background_worker::lock, background_thread::probe, background_thread::probe_cancel_wait, thread, background_worker::threads, vlc_cond_signal(), vlc_list_foreach, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by FetcherThread(), on_thumbnailer_input_event(), and OnParserEnded().