Skip to main content

firehazard/job/
job_handles.rs

1use crate::*;
2
3use winapi::ctypes::c_void;
4
5use core::marker::PhantomData;
6
7
8
9/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/procthread/job-objects)\]
10/// _Owned_ `HANDLE` to a job
11#[repr(transparent)] pub struct OwnedHandle(HANDLENN);
12
13/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/procthread/job-objects)\]
14/// _Borrowed_ `HANDLE` to a job
15#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
16#[repr(transparent)] pub struct Handle<'a>(HANDLENN, PhantomData<&'a HANDLENN>);
17
18// No psuedo job handles?
19
20handles!(unsafe impl *LocalHandleNN<c_void>         for job::{OwnedHandle, Handle<'_>});
21handles!(unsafe impl AsRef<Self>                    for job::{OwnedHandle, Handle<'_>});
22handles!(unsafe impl Send                           for job::{OwnedHandle});
23handles!(unsafe impl {AsRef, From}                  for job::{OwnedHandle, Handle<'_>});
24handles!(unsafe impl {AsRef<@base>, From<@base>}    for job::{OwnedHandle, Handle<'_>});
25handles!(impl Debug                                 for job::{OwnedHandle, Handle<'_>});
26
27impl Drop for OwnedHandle { fn drop(&mut self) { unsafe { drop_close_handle_nn(self) } } }