[−][src]Trait lv2_worker::Worker
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.
Associated Types
type WorkData: 'static + Send
Type of data sent to work
by the schedule handler.
type ResponseData: 'static + Send
Type of data sent to work_response
by the response handler.
Required methods
fn work(
response_handler: &ResponseHandler<Self>,
data: Self::WorkData
) -> Result<(), WorkerError>
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
fn work_response(
&mut self,
_data: Self::ResponseData,
_features: &mut Self::AudioFeatures
) -> Result<(), WorkerError>
&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.
fn end_run(
&mut self,
_features: &mut Self::AudioFeatures
) -> Result<(), WorkerError>
&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.