pub trait Worker: Plugin {
type WorkData: 'static + Send;
type ResponseData: 'static + Send;
// Required method
fn work(
response_handler: &ResponseHandler<Self>,
data: Self::WorkData,
) -> Result<(), WorkerError>;
// Provided methods
fn work_response(
&mut self,
_data: Self::ResponseData,
_features: &mut Self::AudioFeatures,
) -> Result<(), WorkerError> { ... }
fn end_run(
&mut self,
_features: &mut Self::AudioFeatures,
) -> Result<(), WorkerError> { ... }
}Expand description
The non-realtime working extension for plugins.
This trait and the Schedule struct enable plugin creators to use the
Worker specification for non-realtime working
tasks.
In order to be used by the host, you need to to export the WorkerDescriptor
in the extension_data method. You can do that with the match_extensions macro from the lv2-core crate.
Required Associated Types§
Sourcetype ResponseData: 'static + Send
type ResponseData: 'static + Send
Type of data sent to work_response by the response handler.
Required Methods§
Sourcefn work(
response_handler: &ResponseHandler<Self>,
data: Self::WorkData,
) -> Result<(), WorkerError>
fn work( response_handler: &ResponseHandler<Self>, data: Self::WorkData, ) -> Result<(), WorkerError>
The work to do in a non-real-time context,
This is called by the host in a non-realtime context as requested, probably in a separate
thread from run() and possibly with an arbitrary message to handle.
A response can be sent to run() context using the response handler. The plugin MUST NOT make any assumptions
about which thread calls this method, except that there are no real-time requirements and
only one call may be executed at a time. That is, the host MAY call this method from any
non-real-time thread, but MUST NOT make concurrent calls to this method from several
threads.
Provided Methods§
Sourcefn work_response(
&mut self,
_data: Self::ResponseData,
_features: &mut Self::AudioFeatures,
) -> Result<(), WorkerError>
fn work_response( &mut self, _data: Self::ResponseData, _features: &mut Self::AudioFeatures, ) -> Result<(), WorkerError>
Handle a response from the worker.
This is called by the host in the run() context when a response from the worker is ready.
Sourcefn end_run(
&mut self,
_features: &mut Self::AudioFeatures,
) -> Result<(), WorkerError>
fn end_run( &mut self, _features: &mut Self::AudioFeatures, ) -> Result<(), WorkerError>
Called when all responses for this cycle have been delivered.
Since work_response() may be called after run() finished, this method provides a hook for code that
must run after the cycle is completed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.