Driver: Add ability to clear all global event handlers.

Closes #32. This should make event handler cleanup considerably easier depending on use case.
This commit is contained in:
Kyle Simpson
2021-01-17 21:29:19 +00:00
parent dcb6ad97b2
commit 55b8e7fb4e
6 changed files with 18 additions and 0 deletions

View File

@@ -238,6 +238,12 @@ impl Driver {
self.send(CoreMessage::AddEvent(EventData::new(event, action)));
}
/// Removes all global event handlers from an audio context.
#[instrument(skip(self))]
pub fn remove_all_global_events(&mut self) {
self.send(CoreMessage::RemoveGlobalEvents);
}
/// Sends a message to the inner tasks, restarting it if necessary.
fn send(&mut self, status: CoreMessage) {
// Restart thread if it errored.