;
// // TODO: Add this next
// fn set_parameter(&self, param: &P, value: P::Plain)
// where
// P: Param;
}
/// A trait describing the functionality of the platform-specific event loop that can execute tasks
/// of type `T` in executor `E`. Posting a task to the internal task queue should be realtime safe.
/// This event loop should be created during the wrapper's initial initialization on the main
/// thread.
///
/// This is never used generically, but having this as a trait will cause any missing functions on
/// an implementation to show up as compiler errors even when using a different platform.
///
/// TODO: At some point rethink the design to make it possible to have a singleton message queue for
/// all instances of a plugin.
pub(crate) trait EventLoop
where
T: Send,
E: MainThreadExecutor,
{
/// Create and start a new event loop. The thread this is called on will be designated as the
/// main thread, so this should be called when constructing the wrapper.
fn new_and_spawn(executor: Weak) -> Self;
/// Either post the function to the task queue so it can be delegated to the main thread, or
/// execute the task directly if this is the main thread. This function needs to be callable at
/// any time without blocking.
///
/// If the task queue is full, then this will return false.
#[must_use]
fn do_maybe_async(&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.
fn is_main_thread(&self) -> bool;
}
/// Something that can execute tasks of type `T`.
pub(crate) trait MainThreadExecutor: Send + Sync {
/// Execute a task on the current thread. This shoudl only be called from the main thread.
unsafe fn execute(&self, task: T);
}