Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/distrho/src/clap/ext/thread-check.h @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 #pragma once | |
2 | |
3 #include "../plugin.h" | |
4 | |
5 static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_CHECK[] = "clap.thread-check"; | |
6 | |
7 #ifdef __cplusplus | |
8 extern "C" { | |
9 #endif | |
10 | |
11 /// @page thread-check | |
12 /// | |
13 /// CLAP defines two symbolic threads: | |
14 /// | |
15 /// main-thread: | |
16 /// This is the thread in which most of the interaction between the plugin and host happens. | |
17 /// It is usually the thread on which the GUI receives its events. | |
18 /// It isn't a realtime thread, yet this thread needs to respond fast enough to user interaction, | |
19 /// so it is recommended to run long and expensive tasks such as preset indexing or asset loading | |
20 /// in dedicated background threads. | |
21 /// | |
22 /// audio-thread: | |
23 /// This thread is used for realtime audio processing. Its execution should be as deterministic | |
24 /// as possible to meet the audio interface's deadline (can be <1ms). In other words, there is a | |
25 /// known set of operations that should be avoided: malloc() and free(), mutexes (spin mutexes | |
26 /// are worse), I/O, waiting, ... | |
27 /// The audio-thread is something symbolic, there isn't one OS thread that remains the | |
28 /// audio-thread for the plugin lifetime. As you may guess, the host is likely to have a | |
29 /// thread pool and the plugin.process() call may be scheduled on different OS threads over time. | |
30 /// The most important thing is that there can't be two audio-threads at the same time. All the | |
31 /// functions marked with [audio-thread] **ARE NOT CONCURRENT**. The host may mark any OS thread, | |
32 /// including the main-thread as the audio-thread, as long as it can guarentee that only one OS | |
33 /// thread is the audio-thread at a time. The audio-thread can be seen as a concurrency guard for | |
34 /// all functions marked with [audio-thread]. | |
35 | |
36 // This interface is useful to do runtime checks and make | |
37 // sure that the functions are called on the correct threads. | |
38 // It is highly recommended that hosts implement this extension. | |
39 typedef struct clap_host_thread_check { | |
40 // Returns true if "this" thread is the main thread. | |
41 // [thread-safe] | |
42 bool(CLAP_ABI *is_main_thread)(const clap_host_t *host); | |
43 | |
44 // Returns true if "this" thread is one of the audio threads. | |
45 // [thread-safe] | |
46 bool(CLAP_ABI *is_audio_thread)(const clap_host_t *host); | |
47 } clap_host_thread_check_t; | |
48 | |
49 #ifdef __cplusplus | |
50 } | |
51 #endif |