Struct nih_plug::context::gui::AsyncExecutor
source · pub struct AsyncExecutor<P: Plugin> { /* private fields */ }
Expand description
An way to run background tasks from the plugin’s GUI, equivalent to the
ProcessContext::execute_background()
and 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
This is only intended to be used from the GUI. Use the methods on
InitContext
and
ProcessContext
to run tasks during the initialize()
and
process()
functions.
Implementations§
source§impl<P: Plugin> AsyncExecutor<P>
impl<P: Plugin> AsyncExecutor<P>
sourcepub fn execute_background(&self, task: P::BackgroundTask)
pub fn execute_background(&self, task: P::BackgroundTask)
Execute a task on a background thread using [Plugin::task_executor]
. This allows you to
defer expensive tasks for later without blocking either the process function or the 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.
sourcepub fn execute_gui(&self, task: P::BackgroundTask)
pub fn execute_gui(&self, task: P::BackgroundTask)
Execute a task on a background thread using [Plugin::task_executor]
.
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.