dwango / fibers-rs Goto Github PK
View Code? Open in Web Editor NEWA Rust library to execute a number of lightweight asynchronous tasks (a.k.a, fibers) based on futures and mio.
License: MIT License
A Rust library to execute a number of lightweight asynchronous tasks (a.k.a, fibers) based on futures and mio.
License: MIT License
I have the latest Rust stable compiler, a total fresh test project, and fibers does not compile.
λ ~/programming/rust/testing/ master cargo --version
cargo 0.25.0 (96d8071da 2018-02-26)
λ ~/programming/rust/testing/ master rustc --version
rustc 1.24.1 (d3ae9a9e0 2018-02-27)
λ ~/programming/rust/testing/ master cat Cargo.toml
[package]
name = "testing"
version = "0.1.0"
authors = ["Orson Peters <[email protected]>"]
[dependencies]
fibers = "0.1"
λ ~/programming/rust/testing/ master cargo clean
λ ~/programming/rust/testing/ master cargo build
Compiling lazycell v0.6.0
Compiling byteorder v1.2.1
Compiling slab v0.4.0
Compiling cfg-if v0.1.2
Compiling libc v0.2.39
Compiling nbchan v0.1.2
Compiling splay_tree v0.2.9
Compiling futures v0.1.19
Compiling log v0.4.1
Compiling num_cpus v1.8.0
Compiling iovec v0.1.2
Compiling net2 v0.2.32
Compiling mio v0.6.14
Compiling handy_async v0.2.13
Compiling fibers v0.1.9
error[E0599]: no method named `poll` found for type `&mut std::option::Option<sync::oneshot::Monitor<(), std::io::Error>>` in the current scope
--> /home/orlp/.cargo/registry/src/github.com-1ecc6299db9ec823/fibers-0.1.9/src/net/tcp.rs:327:52
|
327 | if let Err(e) = self.monitor(interest).poll() {
| ^^^^
|
= note: the method `poll` exists but the following trait bounds were not satisfied:
`&mut std::option::Option<sync::oneshot::Monitor<(), std::io::Error>> : futures::Future`
`&mut std::option::Option<sync::oneshot::Monitor<(), std::io::Error>> : futures::Stream`
error: aborting due to previous error
error: Could not compile `fibers`.
To learn more, run the command again with --verbose.
Depending on futures 0.1 is causing me headaches, because the traits mismatch (I have two different futures
versions in my dependency tree).
Hi,
Is it somehow possible for an Executor
to be shared between threads and also be used for adding new tasks during runtime?
I am thinking of something like:
// Create a shared executor
let mut executor_mutex = Arc::new(Mutex::new(ThreadPoolExecutor::new().unwrap()));
// Clone it
let ce = executor_mutex.clone();
// A different thread, at some poipnt spawns new tasks on the executor
thread::spawn(move || {
let mut executor = ce.lock().unwrap();
executor.spawn(futures::lazy(|| { println!("Hello"); Ok(())} ));
});
let executor = executor_mutex.lock().unwrap();
// Run the executor
// Not possible, since the run method consumes the executor
executor.run();
I see that there is the run_once
, but I suppose that this blocks until all the units that it includes finish. This would make the executor practically unavailable until then I guess.
On the other hand, I could just create one new executor whenever I wanted to execute some tasks, but then the occupied threads on the system would increase drastically if there are a lot of tasks to be executed and these tasks are long-lived...
Both thread pool and a single-threaded executor can't properly idle because of hard coded 1 millisecond interval for polling:
fibers-rs/src/executor/thread_pool.rs
Line 105 in 84b09e4
fibers-rs/src/executor/in_place.rs
Line 71 in 84b09e4
Timeouts should only be specified while polling when there are active timers running.
How do you handle a mutex with fibers? There is a library for fibers mutex?
I saw that you updated to the 2018 edition of rust recently, but the published version on crates.io is from earlier; maybe it's time to publish a new version?
Interesting crate. How does it compare to tokio? Are futures compatible? Can I use both tokio and fibers in my project? And can I use crates that depend on tokio with fibers?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.