Fix macos build (#186)

* fix compile error

* fix missing function error

* fix undefined behavior issue

* require callback to be `Send`
This commit is contained in:
Andriy Symonovych 2017-12-06 13:13:36 +02:00 committed by tomaka
parent 5105427529
commit 37016e612c
2 changed files with 4 additions and 4 deletions

View File

@ -65,7 +65,7 @@ pub struct EventLoop {
struct ActiveCallbacks { struct ActiveCallbacks {
// Whenever the `run()` method is called with a callback, this callback is put in this list. // Whenever the `run()` method is called with a callback, this callback is put in this list.
callbacks: Mutex<Vec<&'static mut FnMut(VoiceId, UnknownTypeBuffer)>>, callbacks: Mutex<Vec<&'static mut (FnMut(VoiceId, UnknownTypeBuffer) + Send)>>,
} }
struct VoiceInner { struct VoiceInner {
@ -98,9 +98,9 @@ impl EventLoop {
#[inline] #[inline]
pub fn run<F>(&self, mut callback: F) -> ! pub fn run<F>(&self, mut callback: F) -> !
where F: FnMut(VoiceId, UnknownTypeBuffer) where F: FnMut(VoiceId, UnknownTypeBuffer) + Send
{ {
let callback: &mut FnMut(VoiceId, UnknownTypeBuffer) = &mut callback; let callback: &mut (FnMut(VoiceId, UnknownTypeBuffer) + Send) = &mut callback;
self.active_callbacks self.active_callbacks
.callbacks .callbacks
.lock() .lock()

View File

@ -374,7 +374,7 @@ impl EventLoop {
/// You can call the other methods of `EventLoop` without getting a deadlock. /// You can call the other methods of `EventLoop` without getting a deadlock.
#[inline] #[inline]
pub fn run<F>(&self, mut callback: F) -> ! pub fn run<F>(&self, mut callback: F) -> !
where F: FnMut(VoiceId, UnknownTypeBuffer) where F: FnMut(VoiceId, UnknownTypeBuffer) + Send
{ {
self.0.run(move |id, buf| callback(VoiceId(id), buf)) self.0.run(move |id, buf| callback(VoiceId(id), buf))
} }