Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat & refactor(!): Change Default Blocking Handle Behavior & Add Basic Read Op #305

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if [ "${NO_RUN}" != "1" ] && [ "${NO_RUN}" != "true" ]; then
"${CARGO}" test --target "${TARGET}" --no-default-features --features "async-cancel,bytes,legacy,macros,utils"
"${CARGO}" test --target "${TARGET}" --no-default-features --features "async-cancel,bytes,legacy,macros,utils" --release

# enable legacy and sync
"${CARGO}" test --target "${TARGET}" --no-default-features --features "async-cancel,bytes,legacy,macros,utils,sync"
"${CARGO}" test --target "${TARGET}" --no-default-features --features "async-cancel,bytes,legacy,macros,utils,sync" --release

if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${TARGET}" = "i686-unknown-linux-gnu" ]; then
# only enabled uring driver
"${CARGO}" test --target "${TARGET}" --no-default-features --features "async-cancel,bytes,iouring,macros,utils"
Expand Down
2 changes: 1 addition & 1 deletion monoio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ windows-sys = { version = "0.48.0", features = [
"Win32_Networking_WinSock",
"Win32_System_IO",
"Win32_Storage_FileSystem",
"Win32_Security"
"Win32_Security",
] }

# unix dependencies
Expand Down
21 changes: 17 additions & 4 deletions monoio/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,29 @@ pub struct RuntimeBuilder<D> {
scoped_thread_local!(pub(crate) static BUILD_THREAD_ID: usize);

impl<T> Default for RuntimeBuilder<T> {
/// Create a default runtime builder
/// Create a default runtime builder.
///
/// # Note
///
/// When the sync feature is enabled, the default behavior of
/// [monoio::blocking::BlockingStrategy] is to execute tasks on the local thread. In other
/// words, there is no thread pool involved—all blocking I/O operations and heavy computations
/// will block the current thread.
#[must_use]
fn default() -> Self {
RuntimeBuilder::<T>::new()
}
}

impl<T> RuntimeBuilder<T> {
/// Create a default runtime builder
/// Create a default runtime builder.
///
/// # Note
///
/// When the sync feature is enabled, the default behavior of
/// [monoio::blocking::BlockingStrategy] is to execute tasks on the local thread. In other
/// words, there is no thread pool involved—all blocking I/O operations and heavy computations
/// will block the current thread.
#[must_use]
pub fn new() -> Self {
Self {
Expand All @@ -50,7 +64,7 @@ impl<T> RuntimeBuilder<T> {
urb: io_uring::IoUring::builder(),

#[cfg(feature = "sync")]
blocking_handle: crate::blocking::BlockingStrategy::Panic.into(),
blocking_handle: crate::blocking::BlockingStrategy::ExecuteLocal.into(),
_mark: PhantomData,
}
}
Expand Down Expand Up @@ -148,7 +162,6 @@ impl<D> RuntimeBuilder<D> {
/// inner `io_uring` API.
///
/// Refer to the [`io_uring::Builder`] documentation for all the supported methods.

#[cfg(all(target_os = "linux", feature = "iouring"))]
#[must_use]
pub fn uring_builder(mut self, urb: io_uring::Builder) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions monoio/src/driver/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ use std::{
use crate::driver;

pub(crate) mod close;
pub(crate) mod read;
pub(crate) mod write;

mod accept;
mod connect;
mod fsync;
mod open;
mod poll;
mod read;
mod recv;
mod send;
mod write;

#[cfg(unix)]
mod statx;

Expand Down
Loading
Loading