1
0
Fork 0

Rename execute_async() to execute_gui()

We'll have another function that uses a dedicated background thread.
This commit is contained in:
Robbert van der Helm 2022-10-23 13:58:33 +02:00
parent 5d84800c0c
commit 21bfb57023
5 changed files with 13 additions and 13 deletions

View file

@ -68,10 +68,11 @@ pub trait GuiContext: Send + Sync + 'static {
fn set_state(&self, state: PluginState);
}
/// An way to run background tasks from the plugin's GUI, equivalent to
/// [`ProcessContext::execute_async()`][crate::prelude::ProcessContext::execute_async()]. This is
/// passed directly to [`Plugin::editor()`] so the plugin can move it into its editor and use it
/// later.
/// An way to run background tasks from the plugin's GUI, equivalent to the
/// [`ProcessContext::execute_background()`][crate::prelude::ProcessContext::execute_background()]
/// and [`ProcessContext::execute_gui()`][crate::prelude::ProcessContext::execute_gui()] functions.
/// This is passed directly to [`Plugin::editor()`] so the plugin can move it into its editor and
/// use it later.
///
/// # Note
///
@ -103,15 +104,14 @@ pub struct ParamSetter<'a> {
}
impl<P: Plugin> AsyncExecutor<P> {
/// Run a task on a background thread. This allows deferring expensive background tasks for
/// later. This task will likely still be executed on the GUI thread.
/// Run a task from the plugin's GUI thread.
///
/// # Note
///
/// Scheduling the same task multiple times will cause those duplicate tasks to pile up. Try to
/// either prevent this from happening, or check whether the task still needs to be completed in
/// your task executor.
pub fn execute_async(&self, task: P::BackgroundTask) {
pub fn execute_gui(&self, task: P::BackgroundTask) {
(self.inner)(task);
}
}

View file

@ -17,15 +17,15 @@ pub trait ProcessContext<P: Plugin> {
/// Get the current plugin API.
fn plugin_api(&self) -> PluginApi;
/// Run a task on a background thread. This allows deferring expensive background tasks for
/// alter. As long as creating the `task` is realtime-safe, this operation is too.
/// Run a task from the plugin's GUI thread. As long as creating the `task` is realtime-safe,
/// this operation is too.
///
/// # Note
///
/// Scheduling the same task multiple times will cause those duplicate tasks to pile up. Try to
/// either prevent this from happening, or check whether the task still needs to be completed in
/// your task executor.
fn execute_async(&self, task: P::BackgroundTask);
fn execute_gui(&self, task: P::BackgroundTask);
/// Get information about the current transport position and status.
fn transport(&self) -> &Transport;

View file

@ -59,7 +59,7 @@ impl<P: ClapPlugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
PluginApi::Clap
}
fn execute_async(&self, task: P::BackgroundTask) {
fn execute_gui(&self, task: P::BackgroundTask) {
let task_posted = self.wrapper.do_maybe_async(Task::PluginTask(task));
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
}

View file

@ -67,7 +67,7 @@ impl<P: Plugin, B: Backend> ProcessContext<P> for WrapperProcessContext<'_, P, B
PluginApi::Standalone
}
fn execute_async(&self, task: P::BackgroundTask) {
fn execute_gui(&self, task: P::BackgroundTask) {
let task_posted = self.wrapper.event_loop.do_maybe_async(task);
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
}

View file

@ -61,7 +61,7 @@ impl<P: Vst3Plugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
PluginApi::Vst3
}
fn execute_async(&self, task: P::BackgroundTask) {
fn execute_gui(&self, task: P::BackgroundTask) {
let task_posted = self.inner.do_maybe_async(Task::PluginTask(task));
nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
}