compio_driver/
driver_type.rs1#[repr(u8)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum DriverType {
5 Poll,
7 IoUring,
9 IOCP,
11}
12
13impl DriverType {
14 #[cfg(fusion)]
16 pub(crate) fn suggest() -> DriverType {
17 use io_uring::opcode::*;
18
19 const USED_OP: &[u8] = &[
21 Read::CODE,
22 Readv::CODE,
23 Write::CODE,
24 Writev::CODE,
25 Fsync::CODE,
26 Accept::CODE,
27 Connect::CODE,
28 RecvMsg::CODE,
29 SendMsg::CODE,
30 AsyncCancel::CODE,
31 OpenAt::CODE,
32 Close::CODE,
33 Shutdown::CODE,
34 Socket::CODE,
35 ];
36
37 (|| {
38 let uring = io_uring::IoUring::new(2)?;
39 let mut probe = io_uring::Probe::new();
40 uring.submitter().register_probe(&mut probe)?;
41 if USED_OP.iter().all(|op| probe.is_supported(*op)) {
42 std::io::Result::Ok(DriverType::IoUring)
43 } else {
44 Ok(DriverType::Poll)
45 }
46 })()
47 .unwrap_or(DriverType::Poll) }
49
50 pub fn is_polling(&self) -> bool {
52 *self == DriverType::Poll
53 }
54
55 pub fn is_iouring(&self) -> bool {
57 *self == DriverType::IoUring
58 }
59
60 pub fn is_iocp(&self) -> bool {
62 *self == DriverType::IOCP
63 }
64}