Skip to content

Commit

Permalink
Update threads.md
Browse files Browse the repository at this point in the history
  • Loading branch information
toots authored Oct 2, 2024
1 parent fcd8bf4 commit c117033
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/content/threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The main purpose of liquidsoap is to create real time media streams. When stream
is needed to compute them needs to happen very quickly so that we make sure that the stream can in fact
be created in real time.

When a tasks is required that may take some time and whose result is not required for the stream generation,
When a task is required that may take some time and whose result is not required for the stream generation,
for instance when executing a `on_stop` or `on_connect` callback, it can be useful to execute this task in a _thread_.

Threads in liquidsoap are callback functions that are executed by an asynchronous queue. Here's an example:
Expand All @@ -25,19 +25,19 @@ You can decide which queue to send tasks to by using the `queue` parameter of th
`thread.run` functions. Some other operators who also use threads can have a similar
parameter such as `thread_queue` for `request.dynamic` and `playlist`.

```{.liquidsoap include="task-with-queue.liq"}
You can also define your own named queue using the `settings.scheduler.queues` setting.

```{.liquidsoap include="task-with-queue.liq"}
```

You can also define your own named queue using the `settings.scheduler.queues` setting.
This is particularly useful for two applications:

- To control concurrent execution of specific tasks.
- To prevent deadlocks in cases some tasks depends on other tasks.
- To prevent deadlocks in case some tasks depends on other tasks.

Typically, `autocue` data resolution is executed inside a `request` resolution. To
control the concurrency with which this CPU-intensive task is executed, we place them
in specific queues. The number of queues controls how many of these tasks can be executed
in a specific queue. The number of queues controls how many of these tasks can be executed
concurrently.

Also, this prevents a deadlock where all the request resolution fill up the available
Expand Down

0 comments on commit c117033

Please sign in to comment.