Skip to content

Commit

Permalink
Add backend selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexclique committed Jan 24, 2024
1 parent d19539b commit 25bfe00
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/proactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use once_cell::sync::Lazy;
use super::syscore::*;
use super::waker::*;
use crate::spawn_blocking;
use crate::sys::IoBackend;

pub use super::handle::*;

Expand Down Expand Up @@ -39,6 +40,11 @@ impl Proactor {
pub(crate) fn inner(&self) -> &SysProactor {
&self.0
}

/// Get the IO backend that is used with Nuclei's proactor.
pub(crate) fn backend() -> IoBackend {
BACKEND
}
}

///
Expand Down
11 changes: 11 additions & 0 deletions src/sys.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
///
/// Backends that are possible to use with Nuclei
pub enum IoBackend {
/// BSD-like backend
Kqueue,
/// Linux backend
Epoll,
/// Linux backend
IoUring
}

#[cfg(unix)]
fn check_err(res: libc::c_int) -> Result<libc::c_int, std::io::Error> {
if res == -1 {
Expand Down
2 changes: 2 additions & 0 deletions src/syscore/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pub(crate) use fs::*;
pub(crate) use kqueue::*;

pub(crate) use processor::*;

pub const BACKEND: crate::sys::IoBackend = crate::sys::IoBackend::Kqueue;
2 changes: 2 additions & 0 deletions src/syscore/linux/epoll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pub(crate) use epoll::*;
pub(crate) use fs::*;

pub(crate) use processor::*;

pub const BACKEND: crate::sys::IoBackend = crate::sys::IoBackend::Epoll;
2 changes: 2 additions & 0 deletions src/syscore/linux/iouring/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pub(crate) use fs::*;
pub(crate) use iouring::*;
pub(crate) use nethandle::*;
pub(crate) use processor::*;

pub const BACKEND: crate::sys::IoBackend = crate::sys::IoBackend::IoUring;

0 comments on commit 25bfe00

Please sign in to comment.