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

View file

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

View file

@ -59,7 +59,7 @@ impl<P: ClapPlugin> ProcessContext<P> for WrapperProcessContext<'_, P> {
PluginApi::Clap 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)); let task_posted = self.wrapper.do_maybe_async(Task::PluginTask(task));
nih_debug_assert!(task_posted, "The task queue is full, dropping 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 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); let task_posted = self.wrapper.event_loop.do_maybe_async(task);
nih_debug_assert!(task_posted, "The task queue is full, dropping 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 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)); let task_posted = self.inner.do_maybe_async(Task::PluginTask(task));
nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); nih_debug_assert!(task_posted, "The task queue is full, dropping task...");
} }