diff options
Diffstat (limited to 'src/interest.rs')
-rw-r--r-- | src/interest.rs | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/interest.rs b/src/interest.rs index 0aa0bda..50d1bf0 100644 --- a/src/interest.rs +++ b/src/interest.rs @@ -20,18 +20,9 @@ pub struct Interest(NonZeroU8); const READABLE: u8 = 0b0001; const WRITABLE: u8 = 0b0010; // The following are not available on all platforms. -#[cfg_attr( - not(any( - target_os = "dragonfly", - target_os = "freebsd", - target_os = "ios", - target_os = "macos" - )), - allow(dead_code) -)] const AIO: u8 = 0b0100; -#[cfg_attr(not(target_os = "freebsd"), allow(dead_code))] const LIO: u8 = 0b1000; +const PRIORITY: u8 = 0b10000; impl Interest { /// Returns a `Interest` set representing readable interests. @@ -45,7 +36,7 @@ impl Interest { target_os = "dragonfly", target_os = "freebsd", target_os = "ios", - target_os = "macos" + target_os = "macos", ))] pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) }); @@ -53,6 +44,10 @@ impl Interest { #[cfg(target_os = "freebsd")] pub const LIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(LIO) }); + /// Returns a `Interest` set representing priority completion interests. + #[cfg(any(target_os = "linux", target_os = "android"))] + pub const PRIORITY: Interest = Interest(unsafe { NonZeroU8::new_unchecked(PRIORITY) }); + /// Add together two `Interest`. /// /// This does the same thing as the `BitOr` implementation, but is a @@ -104,15 +99,20 @@ impl Interest { (self.0.get() & WRITABLE) != 0 } - /// Returns true if `Interest` contains AIO readiness + /// Returns true if `Interest` contains AIO readiness. pub const fn is_aio(self) -> bool { (self.0.get() & AIO) != 0 } - /// Returns true if `Interest` contains LIO readiness + /// Returns true if `Interest` contains LIO readiness. pub const fn is_lio(self) -> bool { (self.0.get() & LIO) != 0 } + + /// Returns true if `Interest` contains priority readiness. + pub const fn is_priority(self) -> bool { + (self.0.get() & PRIORITY) != 0 + } } impl ops::BitOr for Interest { @@ -152,7 +152,7 @@ impl fmt::Debug for Interest { target_os = "dragonfly", target_os = "freebsd", target_os = "ios", - target_os = "macos" + target_os = "macos", ))] { if self.is_aio() { @@ -173,6 +173,16 @@ impl fmt::Debug for Interest { one = true } } + #[cfg(any(target_os = "linux", target_os = "android"))] + { + if self.is_priority() { + if one { + write!(fmt, " | ")? + } + write!(fmt, "PRIORITY")?; + one = true + } + } debug_assert!(one, "printing empty interests"); Ok(()) } |