diff --git a/Cargo.toml b/Cargo.toml index 3c4b7c4..88aa0e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ [package] name = "fast_log" -version = "1.4.19" +version = "1.4.20" description = "Rust async log High-performance asynchronous logging" readme = "Readme.md" authors = ["ce "] @@ -19,7 +19,7 @@ default = ["runtime_thread"] gzip = ["flate2"] runtime_thread = [] -runtime_cogo = ["cogo"] +runtime_mco = ["mco"] [dependencies] chrono = { version = "0.4", features = ["serde"] } @@ -30,7 +30,7 @@ crossbeam-utils = "0.8" crossbeam = "0.8" crossbeam-channel = "0.5" parking_lot = "0.11" -cogo = {version = "0.1", optional = true } +mco = {version = "0.1", optional = true } once_cell = "1.9" diff --git a/example/Cargo.toml b/example/Cargo.toml index 537bf13..6d8d7b2 100644 --- a/example/Cargo.toml +++ b/example/Cargo.toml @@ -43,7 +43,7 @@ crossbeam-channel = "0.5" crossbeam-utils = "0.8" crossbeam = "0.8" chrono = { version = "0.4", features = ["serde"] } -cogo = "0.1" +mco = "0.1" # features=["lz4"] or add features=["zip","lz4"] if you need lz4 packer fast_log = { path = "../", features = ["lz4","zip","gzip"]} diff --git a/src/runtime.rs b/src/runtime.rs index f985bbd..aa01d94 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -1,75 +1,75 @@ use std::time::Duration; -/// if use cogo runtime -#[cfg(feature = "cogo")] -pub type TcpListener = cogo::net::TcpListener; -#[cfg(feature = "cogo")] -pub type TcpStream = cogo::net::TcpStream; -#[cfg(feature = "cogo")] -pub type Receiver = cogo::std::sync::channel::Receiver; -#[cfg(feature = "cogo")] -pub type Sender = cogo::std::sync::channel::Sender; -#[cfg(feature = "cogo")] -pub type JoinHandle = cogo::coroutine::JoinHandle; -#[cfg(feature = "cogo")] -pub type Mutex = cogo::std::sync::Mutex; -#[cfg(feature = "cogo")] -pub type WaitGroup = cogo::std::sync::WaitGroup; +/// if use mco runtime +#[cfg(feature = "mco")] +pub type TcpListener = mco::net::TcpListener; +#[cfg(feature = "mco")] +pub type TcpStream = mco::net::TcpStream; +#[cfg(feature = "mco")] +pub type Receiver = mco::std::sync::channel::Receiver; +#[cfg(feature = "mco")] +pub type Sender = mco::std::sync::channel::Sender; +#[cfg(feature = "mco")] +pub type JoinHandle = mco::coroutine::JoinHandle; +#[cfg(feature = "mco")] +pub type Mutex = mco::std::sync::Mutex; +#[cfg(feature = "mco")] +pub type WaitGroup = mco::std::sync::WaitGroup; -#[cfg(feature = "cogo")] +#[cfg(feature = "mco")] pub fn chan() -> (Sender, Receiver) { - cogo::chan!() + mco::chan!() } -#[cfg(feature = "cogo")] +#[cfg(feature = "mco")] pub fn sleep(d: Duration) { - cogo::coroutine::sleep(d) + mco::coroutine::sleep(d) } -#[cfg(feature = "cogo")] +#[cfg(feature = "mco")] pub fn spawn(f: F) -> JoinHandle<()> where F: FnOnce() + std::marker::Send + 'static { - cogo::coroutine::Builder::new().stack_size(0x1000).spawn(f) + mco::coroutine::Builder::new().stack_size(0x1000).spawn(f) } -#[cfg(feature = "cogo")] +#[cfg(feature = "mco")] pub fn spawn_stack_size(f: F, stack_size:usize) -> JoinHandle<()> where F: FnOnce() + std::marker::Send + 'static { - cogo::coroutine::Builder::new().stack_size(stack_size).spawn(f) + mco::coroutine::Builder::new().stack_size(stack_size).spawn(f) } -/// if not cogo -#[cfg(not(feature = "cogo"))] +/// if not mco +#[cfg(not(feature = "mco"))] pub type TcpListener = std::net::TcpListener; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type TcpStream = std::net::TcpStream; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type Receiver = crossbeam::channel::Receiver; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type Sender = crossbeam::channel::Sender; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type JoinHandle = std::thread::JoinHandle; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type Mutex = std::sync::Mutex; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub type WaitGroup = crossbeam_utils::sync::WaitGroup; -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub fn chan() -> (Sender, Receiver) { crossbeam::channel::unbounded() } -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub fn sleep(d: Duration) { std::thread::sleep(d) } -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub fn spawn(f: F) -> JoinHandle<()> where F: FnOnce() + std::marker::Send + 'static { std::thread::spawn(f) } -#[cfg(not(feature = "cogo"))] +#[cfg(not(feature = "mco"))] pub fn spawn_stack_size(f: F, stack_size:usize) -> JoinHandle<()> where F: FnOnce() + std::marker::Send + 'static { std::thread::spawn(f) } \ No newline at end of file