VLC  3.0.15
Data Structures | Functions
background_worker.h File Reference

Go to the source code of this file.

Data Structures

struct  background_worker_config
 

Functions

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.

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

References BackgroundWorkerCancel().

Referenced by playlist_preparser_Cancel(), and playlist_preparser_Deactivate().

◆ 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.

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

References BackgroundWorkerCancel(), background_worker::data, background_worker::head, background_worker::lock, background_worker::tail, vlc_array_clear(), vlc_cond_destroy(), vlc_mutex_destroy(), background_worker::wait, and background_worker::worker_wait.

Referenced by playlist_fetcher_Delete(), playlist_fetcher_New(), and playlist_preparser_Delete().

◆ 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.

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

References background_worker::active, background_worker::conf, background_worker::data, background_worker::deadline, background_worker::head, background_worker::id, background_worker::lock, background_worker::owner, background_worker::tail, unlikely, vlc_array_init(), vlc_cond_init(), vlc_mutex_init(), VLC_TS_INVALID, background_worker::wait, and background_worker::worker_wait.

Referenced by playlist_preparser_New(), 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).

Parameters
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.
Returns
VLC_SUCCESS if the entity was successfully queued, an error-code on failure.

< Unspecified error

< Unspecified error

< No error

< Unspecified error

References background_worker::active, background_worker::conf, background_worker::data, background_worker_config::default_timeout, bg_queued_item::entity, background_worker::head, bg_queued_item::id, background_worker::lock, background_worker_config::pf_hold, background_worker::probe_request, background_worker::tail, Thread(), bg_queued_item::timeout, unlikely, vlc_array_append(), vlc_clone_detach(), vlc_cond_signal(), VLC_EGENERIC, vlc_mutex_lock(), vlc_mutex_unlock(), VLC_SUCCESS, VLC_THREAD_PRIORITY_LOW, and background_worker::wait.

Referenced by playlist_fetcher_Push(), playlist_preparser_Push(), SearchByScope(), and SearchLocal().

◆ 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.

Warning
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.
Parameters
workerthe background-worker

References background_worker::head, background_worker::lock, background_worker::probe_request, vlc_cond_signal(), vlc_mutex_lock(), vlc_mutex_unlock(), and background_worker::worker_wait.

Referenced by FetcherThread(), and InputEvent().