Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 609f728

Browse files
committed
refactor(io)!: use synchrony for split
1 parent 7a1f6c3 commit 609f728

7 files changed

Lines changed: 31 additions & 287 deletions

File tree

compio-io/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repository = { workspace = true }
1414
compio-buf = { workspace = true, features = ["arrayvec", "bytes"] }
1515
futures-util = { workspace = true, features = ["sink"] }
1616
paste = { workspace = true }
17+
synchrony = { workspace = true, features = ["bilock"] }
1718
thiserror = { workspace = true, optional = true }
1819
serde = { version = "1.0.219", optional = true }
1920
serde_json = { version = "1.0.140", optional = true }
@@ -28,6 +29,7 @@ futures-executor = "0.3.30"
2829
[features]
2930
default = []
3031
compat = ["futures-util/io"]
32+
sync = []
3133

3234
# Codecs
3335
# Serde json codec

compio-io/src/framed/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ impl<R, W, C, F, In, Out> Framed<R, W, C, F, In, Out> {
7171
///
7272
/// Some types like the ones mentioned above are multiplexed by nature, so
7373
/// they implement the [`Splittable`] trait by themselves. For other types,
74-
/// you may want to wrap them in [`Split`] or [`UnsyncSplit`] first, which
75-
/// uses lock or `RefCell` under the hood.
74+
/// you may want to wrap them in [`Split`] first, which uses lock or
75+
/// `RefCell` under the hood.
7676
///
7777
/// [`Split`]: crate::util::split::Split
78-
/// [`UnsyncSplit`]: crate::util::split::UnsyncSplit
7978
pub fn with_duplex<Io: Splittable>(
8079
self,
8180
io: Io,

compio-io/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
#![cfg_attr(docsrs, feature(doc_cfg))]
115115

116116
use std::{future::Future, pin::Pin};
117+
118+
#[cfg(feature = "sync")]
119+
use synchrony::sync;
120+
#[cfg(not(feature = "sync"))]
121+
use synchrony::unsync as sync;
122+
117123
type PinBoxFuture<T> = Pin<Box<dyn Future<Output = T>>>;
118124

119125
mod buffer;
@@ -129,8 +135,5 @@ pub(crate) type IoResult<T> = std::io::Result<T>;
129135

130136
pub use read::*;
131137
#[doc(inline)]
132-
pub use util::{
133-
copy, null, repeat,
134-
split::{split, split_unsync},
135-
};
138+
pub use util::{copy, null, repeat, split::split};
136139
pub use write::*;

compio-io/src/util/bilock.rs

Lines changed: 0 additions & 141 deletions
This file was deleted.

compio-io/src/util/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! IO related utilities functions for ease of use.
22
use crate::{AsyncRead, AsyncWrite, AsyncWriteExt, IoResult};
33

4-
mod bilock;
5-
64
mod take;
75
pub use take::Take;
86

0 commit comments

Comments
 (0)