Skip to content

Commit

Permalink
Make it send.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Nov 11, 2020
1 parent a51fad8 commit 230effb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,14 @@ mod tests {
.await;
});
}

#[test]
fn test_is_send() {
futures_lite::future::block_on(async {
fn is_send<T: Send>(_: T) {}
is_send(AddrSet::new());
is_send(AddrSet::new().await.unwrap());
is_send(AddrSet::new().await.unwrap().next());
});
}
}
6 changes: 4 additions & 2 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct RouteChangeNotification {
}

/// The type of route change callbacks
type RouteChangeCallback = Box<dyn FnMut(&MIB_IPINTERFACE_ROW, MIB_NOTIFICATION_TYPE) + Send>;
type RouteChangeCallback = Box<dyn Fn(&MIB_IPINTERFACE_ROW, MIB_NOTIFICATION_TYPE) + Send>;
impl RouteChangeNotification {
/// Register for route change notifications
fn new(cb: RouteChangeCallback) -> std::io::Result<Self> {
Expand All @@ -98,7 +98,7 @@ impl RouteChangeNotification {
Row: *mut MIB_IPINTERFACE_ROW,
NotificationType: MIB_NOTIFICATION_TYPE,
) {
(**(CallerContext as *mut RouteChangeCallback))(&*Row, NotificationType)
(**(CallerContext as *const RouteChangeCallback))(&*Row, NotificationType)
}
let mut handle = core::ptr::null_mut();
let callback = Box::into_raw(Box::new(cb));
Expand Down Expand Up @@ -128,6 +128,8 @@ impl Drop for RouteChangeNotification {
}
}

unsafe impl Send for RouteChangeNotification {}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 230effb

Please sign in to comment.