Comments (2)
I wonder if a function I wrote recently is related to this issue:
/// With a shared reactor drives the future `f` to completion.
///
/// NB: This function is only useful if you need to get the results of the execution.
/// If the results are not necessary then a future can be scheduled directly on the reactor:
///
/// CORE.spawn (|_| f);
pub fn drive<F, R, E> (f: F) -> Receiver<Result<R, E>> where F: Future<Item=R, Error=E> + Send + 'static, R: Send + 'static, E: Send + 'static {
let (sx, rx) = oneshot::channel();
CORE.spawn (move |_handle| {
f.then (move |fr: Result<R, E>| -> Result<(),()> {
let _ = sx.send (fr);
Ok(())})});
rx}
/// Drives the future to completion. Logs any errors.
///
/// NB: If the future returns `(),()` then use the `CORE.spawn (|_| f)` directly.
pub fn later<F, R, E> (f: F) where F: Future<Item=R, Error=E> + Send + 'static, R: Send + 'static, E: fmt::Display + Send + 'static {
CORE.spawn (|_handle| f.then (move |fr| -> Result<(),()> {
if let Err (err) = fr {log! ("later] Error: {}", err)}
Ok(())}))}
from tokio-core.
I believe this will be obsoleted by rust-lang/futures-rs#455, so closing
from tokio-core.
Related Issues (20)
- panic at "no Task is currently running" HOT 1
- Problem with global variable lifetime in a single threaded context. HOT 1
- Udp `recv` isn't implemented as borrow
- UdpFramed doesn't return incoming frames HOT 4
- cargo update -> CPU at 100% while idle HOT 6
- 0.1.13 breaks registering an fd on multiple event loops HOT 4
- Updating from 0.1.12 to 0.1.14 breaks code HOT 5
- Remote-related bug in tokio-core >= 0.1.13 HOT 3
- Cannot tokio::spawn from Core::run HOT 1
- Regression with Timeouts and/or UdpSockets? HOT 6
- Backport critical fix in PollEvented from tokio crate HOT 3
- cannot recursively call into Core HOT 12
- Updating to 0.1.17 causes a hang relating to timeouts HOT 11
- TCP_KEEPINTVL / TCP_KEEPCNT missing HOT 1
- Getting a Illegal instruction segfault on arm (Raspberry Pi 1) HOT 1
- Server goes in uncontrolled cycles HOT 1
- Build for wasm32-unknown-unknown
- Compilation error for version 0.1.9 HOT 1
- Proxy example - is reconnecting to the server every loop necessary?
- tests no longer compile due to the removal of the `tokio` feature in `flate2`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio-core.