VLC  4.0.0-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Fields
background_worker_config Struct Reference

Data Fields

vlc_tick_t default_timeout
 Default timeout for completing a task. More...
 
int max_threads
 Maximum number of threads used to execute tasks. More...
 
void(* pf_release )(void *entity)
 Release an entity. More...
 
void(* pf_hold )(void *entity)
 Hold a queued item. More...
 
int(* pf_start )(void *owner, void *entity, void **out)
 Start a new task. More...
 
int(* pf_probe )(void *owner, void *handle)
 Probe a running task. More...
 
void(* pf_stop )(void *owner, void *handle)
 Stop a running task. More...
 

Field Documentation

◆ default_timeout

vlc_tick_t background_worker_config::default_timeout

Default timeout for completing a task.

If less-than 0 a task can run indefinitely without being killed, whereas a positive value denotes the maximum number of milliseconds a task can run before pf_stop is called to kill it.

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

◆ max_threads

int background_worker_config::max_threads

Maximum number of threads used to execute tasks.

Referenced by background_worker_Push().

◆ pf_hold

void( * background_worker_config::pf_hold) (void *entity)

Hold a queued item.

This callback will be called in order to increment the ref-count of an entity. It will happen when the entity is pushed into the queue of pending tasks as part of background_worker_Push.

Warning
As each task might be executed in parallel by different threads, this callback must be thread-safe.
Parameters
entitythe entity to hold

Referenced by task_Create().

◆ pf_probe

int( * background_worker_config::pf_probe) (void *owner, void *handle)

Probe a running task.

This callback is called in order to see whether or not a running task has finished or not. It can be called anytime between a successful call to pf_start, and the corresponding call to pf_stop.

Warning
As each task might be executed in parallel by different threads, this callback must be thread-safe.
Parameters
ownerthe owner of the background-worker
handlethe handle associated with the running task
Returns
0 if the task is still running, any other value if finished.

Referenced by Thread().

◆ pf_release

void( * background_worker_config::pf_release) (void *entity)

Release an entity.

This callback will be called in order to decrement the ref-count of a entity within the background-worker. It will happen either when pf_stop has finished executing, or if the entity is removed from the queue (through background_worker_Cancel)

Warning
As each task might be executed in parallel by different threads, this callback must be thread-safe.
Parameters
entitythe entity to release

Referenced by task_Destroy().

◆ pf_start

int( * background_worker_config::pf_start) (void *owner, void *entity, void **out)

Start a new task.

This callback is called in order to construct a new background task. In order for the background-worker to be able to continue processing incoming requests, pf_start is meant to start a task (such as a thread), and then store the associated handle in *out.

The value of *out will then be the value of the argument named handle in terms of pf_probe and pf_stop.

Warning
As each task might be executed in parallel by different threads, this callback must be thread-safe.
Parameters
ownerthe owner of the background-worker
entitythe entity for which a task is to be created
out[out] *out shall, on success, refer to the handle associated with the running task.
Returns
VLC_SUCCESS if a task was created, an error-code on failure.

Referenced by Thread().

◆ pf_stop

void( * background_worker_config::pf_stop) (void *owner, void *handle)

Stop a running task.

This callback is called in order to stop a running task. If pf_start has created a non-detached thread, pf_stop is where you would interrupt and then join it.

Warning
This function is called either after pf_probe has stated that the task has finished, or if the timeout (if any) for the task has been reached.
As each task might be executed in parallel by different threads, this callback must be thread-safe.
Parameters
ownerthe owner of the background-worker handle the handle associated with the task to be stopped

Referenced by Thread().


The documentation for this struct was generated from the following file: