diff --git a/src/context/init.rs b/src/context/init.rs index 107a8f0f..bd896d96 100644 --- a/src/context/init.rs +++ b/src/context/init.rs @@ -9,7 +9,7 @@ use crate::plugin::Plugin; // # Safety // // The implementing wrapper needs to be able to handle concurrent requests, and it should perform -// the actual callback within [MainThreadQueue::do_maybe_async]. +// the actual callback within [MainThreadQueue::schedule_gui]. pub trait InitContext { /// Get the current plugin API. fn plugin_api(&self) -> PluginApi; diff --git a/src/context/process.rs b/src/context/process.rs index f3f57e7e..1ca1c69f 100644 --- a/src/context/process.rs +++ b/src/context/process.rs @@ -12,7 +12,7 @@ use crate::plugin::Plugin; // # Safety // // The implementing wrapper needs to be able to handle concurrent requests, and it should perform -// the actual callback within [MainThreadQueue::do_maybe_async]. +// the actual callback within [MainThreadQueue::schedule_gui]. pub trait ProcessContext { /// Get the current plugin API. fn plugin_api(&self) -> PluginApi; diff --git a/src/event_loop.rs b/src/event_loop.rs index 0d786242..59cb587a 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -46,7 +46,7 @@ where /// /// If the task queue is full, then this will return false. #[must_use] - fn do_maybe_async(&self, task: T) -> bool; + fn schedule_gui(&self, task: T) -> bool; /// Whether the calling thread is the event loop's main thread. This is usually the thread the /// event loop instance was initialized on. diff --git a/src/event_loop/linux.rs b/src/event_loop/linux.rs index 5de51f63..d5e0c713 100644 --- a/src/event_loop/linux.rs +++ b/src/event_loop/linux.rs @@ -25,7 +25,7 @@ pub(crate) struct LinuxEventLoop { /// queue. main_thread_id: ThreadId, - /// A thread that act as our worker thread. When [`do_maybe_async()`][Self::do_maybe_async()] is + /// A thread that act as our worker thread. When [`schedule_gui()`][Self::schedule_gui()] is /// called, this thread will be woken up to execute the task on the executor. This is wrapped in /// an `Option` so the thread can be taken out of it and joined when this struct gets dropped. worker_thread: Option>, @@ -64,7 +64,7 @@ where } } - fn do_maybe_async(&self, task: T) -> bool { + fn schedule_gui(&self, task: T) -> bool { if self.is_main_thread() { self.executor.execute(task, true); true diff --git a/src/event_loop/windows.rs b/src/event_loop/windows.rs index 19973234..55a136ac 100644 --- a/src/event_loop/windows.rs +++ b/src/event_loop/windows.rs @@ -132,7 +132,7 @@ where } } - fn do_maybe_async(&self, task: T) -> bool { + fn schedule_gui(&self, task: T) -> bool { if self.is_main_thread() { self.executor.execute(task, true); true diff --git a/src/wrapper/clap/context.rs b/src/wrapper/clap/context.rs index d872d463..7c176484 100644 --- a/src/wrapper/clap/context.rs +++ b/src/wrapper/clap/context.rs @@ -60,7 +60,7 @@ impl ProcessContext

for WrapperProcessContext<'_, P> { } fn execute_gui(&self, task: P::BackgroundTask) { - let task_posted = self.wrapper.do_maybe_async(Task::PluginTask(task)); + let task_posted = self.wrapper.schedule_gui(Task::PluginTask(task)); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 297d3587..0eaab262 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -320,7 +320,7 @@ impl EventLoop, Wrapper

> for Wrapper

{ panic!("What are you doing"); } - fn do_maybe_async(&self, task: Task

) -> bool { + fn schedule_gui(&self, task: Task

) -> bool { if self.is_main_thread() { self.execute(task, true); true @@ -692,7 +692,7 @@ impl Wrapper

{ let wrapper = wrapper.clone(); move |task| { - let task_posted = wrapper.do_maybe_async(Task::PluginTask(task)); + let task_posted = wrapper.schedule_gui(Task::PluginTask(task)); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } }), @@ -1649,7 +1649,7 @@ impl Wrapper

{ } // After the state has been updated, notify the host about the new parameter values - let task_posted = self.do_maybe_async(Task::RescanParamValues); + let task_posted = self.schedule_gui(Task::RescanParamValues); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } @@ -1659,7 +1659,7 @@ impl Wrapper

{ // to keep doing it this way to stay consistent with VST3. let old_latency = self.current_latency.swap(samples, Ordering::SeqCst); if old_latency != samples { - let task_posted = self.do_maybe_async(Task::LatencyChanged); + let task_posted = self.schedule_gui(Task::LatencyChanged); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } } @@ -1677,7 +1677,7 @@ impl Wrapper

{ if clamped_capacity != self.current_voice_capacity.load(Ordering::Relaxed) { self.current_voice_capacity .store(clamped_capacity, Ordering::Relaxed); - let task_posted = self.do_maybe_async(Task::VoiceInfoChanged); + let task_posted = self.schedule_gui(Task::VoiceInfoChanged); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } } @@ -2353,7 +2353,7 @@ impl Wrapper

{ check_null_ptr!((), plugin); let wrapper = &*(plugin as *const Self); - // [Self::do_maybe_async] posts a task to the queue and asks the host to call this function + // [Self::schedule_gui] posts a task to the queue and asks the host to call this function // on the main thread, so once that's done we can just handle all requests here while let Some(task) = wrapper.tasks.pop() { wrapper.execute(task, true); diff --git a/src/wrapper/standalone/context.rs b/src/wrapper/standalone/context.rs index a24dbb7f..3d216006 100644 --- a/src/wrapper/standalone/context.rs +++ b/src/wrapper/standalone/context.rs @@ -68,7 +68,7 @@ impl ProcessContext

for WrapperProcessContext<'_, P, B } 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.schedule_gui(task); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } diff --git a/src/wrapper/standalone/wrapper.rs b/src/wrapper/standalone/wrapper.rs index f17cafd0..ca7cc44c 100644 --- a/src/wrapper/standalone/wrapper.rs +++ b/src/wrapper/standalone/wrapper.rs @@ -246,7 +246,7 @@ impl Wrapper { let wrapper = wrapper.clone(); move |task| { - let task_posted = wrapper.event_loop.do_maybe_async(task); + let task_posted = wrapper.event_loop.schedule_gui(task); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } }), diff --git a/src/wrapper/vst3/context.rs b/src/wrapper/vst3/context.rs index 219dc273..3f1e7859 100644 --- a/src/wrapper/vst3/context.rs +++ b/src/wrapper/vst3/context.rs @@ -62,7 +62,7 @@ impl ProcessContext

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

{ } fn request_resize(&self) -> bool { - let task_posted = self.inner.do_maybe_async(Task::RequestResize); + let task_posted = self.inner.schedule_gui(Task::RequestResize); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); // TODO: We don't handle resize request failures right now. In practice this should however diff --git a/src/wrapper/vst3/inner.rs b/src/wrapper/vst3/inner.rs index efc52fc6..cb05c5a4 100644 --- a/src/wrapper/vst3/inner.rs +++ b/src/wrapper/vst3/inner.rs @@ -55,7 +55,7 @@ pub(crate) struct WrapperInner { /// A realtime-safe task queue so the plugin can schedule tasks that need to be run later on the /// GUI thread. This field should not be used directly for posting tasks. This should be done - /// through [`Self::do_maybe_async()`] instead. That method posts the task to the host's + /// through [`Self::schedule_gui()`] instead. That method posts the task to the host's /// `IRunLoop` instead of it's available. /// /// This AtomicRefCell+Option is only needed because it has to be initialized late. There is no @@ -340,7 +340,7 @@ impl WrapperInner

{ let wrapper = wrapper.clone(); move |task| { - let task_posted = wrapper.do_maybe_async(Task::PluginTask(task)); + let task_posted = wrapper.schedule_gui(Task::PluginTask(task)); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } }), @@ -367,13 +367,13 @@ impl WrapperInner

{ } } - /// Either posts the function to the task queue using [`EventLoop::do_maybe_async()`] so it can + /// Either posts the function to the task queue using [`EventLoop::schedule_gui()`] so it can /// be delegated to the main thread, executes the task directly if this is the main thread, or /// runs the task on the host's `IRunLoop` if the GUI is open and it exposes one. This function /// /// If the task queue is full, then this will return false. #[must_use] - pub fn do_maybe_async(&self, task: Task

) -> bool { + pub fn schedule_gui(&self, task: Task

) -> bool { let event_loop = self.event_loop.borrow(); let event_loop = event_loop.as_ref().unwrap(); if event_loop.is_main_thread() { @@ -388,9 +388,9 @@ impl WrapperInner

{ match &*self.plug_view.read() { Some(plug_view) => match plug_view.do_maybe_in_run_loop(task) { Ok(()) => true, - Err(task) => event_loop.do_maybe_async(task), + Err(task) => event_loop.schedule_gui(task), }, - None => event_loop.do_maybe_async(task), + None => event_loop.schedule_gui(task), } } } @@ -517,7 +517,7 @@ impl WrapperInner

{ .borrow() .as_ref() .unwrap() - .do_maybe_async(Task::TriggerRestart( + .schedule_gui(Task::TriggerRestart( RestartFlags::kParamValuesChanged as i32, )); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); @@ -528,7 +528,7 @@ impl WrapperInner

{ let old_latency = self.current_latency.swap(samples, Ordering::SeqCst); if old_latency != samples { let task_posted = - self.do_maybe_async(Task::TriggerRestart(RestartFlags::kLatencyChanged as i32)); + self.schedule_gui(Task::TriggerRestart(RestartFlags::kLatencyChanged as i32)); nih_debug_assert!(task_posted, "The task queue is full, dropping task..."); } } diff --git a/src/wrapper/vst3/view.rs b/src/wrapper/vst3/view.rs index 989b62bd..537bc893 100644 --- a/src/wrapper/vst3/view.rs +++ b/src/wrapper/vst3/view.rs @@ -515,7 +515,7 @@ impl Drop for RunLoopEventHandler

{ .borrow() .as_ref() .unwrap() - .do_maybe_async(task); + .schedule_gui(task); } if posting_failed {