Skip to content

Instantly share code, notes, and snippets.

@Amanieu
Last active March 23, 2018 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amanieu/bb991fe44d0ab9ab40f9c1d585d809dd to your computer and use it in GitHub Desktop.
Save Amanieu/bb991fe44d0ab9ab40f9c1d585d809dd to your computer and use it in GitHub Desktop.
struct SendHandle {
handle: Handle,
guard: Option<Guard>,
}
unsafe impl Send for SendHandle {}
impl SendHandle {
pub fn new(handle: Handle) -> SendHandle {
SendHandle {
handle,
guard: None,
}
}
pub fn pin(&mut self) -> &mut Guard {
let handle = &mut self.handle;
self.guard.get_or_insert_with(|| handle.pin())
}
pub fn unpin(&mut self) {
self.guard = None;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment