You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
The code below cannot be compiled. That seems to be because Box<Future> is not Send. While #[async(boxed)] is not necessary and #[async] works well instead here, it's better to support some kind of boxed generator which is Send as they would be common in complex applications (e.g. when writing recursive functions.)
This issue may be related to #15 because the problem is caused by trait objects. I guess something like Box<G> where G: Generator fixes it. Or some way to support Box<Future + Send>?
#![feature(proc_macro, generators)]externcrate futures_await as futures;externcrate futures_cpupool;use futures::prelude::*;use futures_cpupool::*;#[async(boxed)]fnfoo() -> Result<(),()>{Ok(())}fnmain(){CpuPool::new_num_cpus().spawn(foo()).wait();}
Build log:
> cargo build
Compiling rust-async-await-examples v0.1.0 (file:///home/raviqqe/src/github.com/raviqqe/rust-async-await-examples)
error[E0277]: the trait bound `futures::Future<Error=(), Item=()>: std::marker::Send` is not satisfied
--> src/main.rs:15:29
|
15 | CpuPool::new_num_cpus().spawn(foo()).wait();
| ^^^^^ `futures::Future<Error=(), Item=()>` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `futures::Future<Error=(), Item=()>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<futures::Future<Error=(), Item=()>>`
= note: required because it appears within the type `std::boxed::Box<futures::Future<Error=(), Item=()>>`
error: aborting due to previous error
error: Could not compile `rust-async-await-examples`.
To learn more, run the command again with --verbose.
The text was updated successfully, but these errors were encountered:
raviqqe
changed the title
futures-cpupool support of boxed future
futures-cpupool support with boxed future
Feb 7, 2018
The code below cannot be compiled. That seems to be because
Box<Future>
is notSend
. While#[async(boxed)]
is not necessary and#[async]
works well instead here, it's better to support some kind of boxed generator which isSend
as they would be common in complex applications (e.g. when writing recursive functions.)This issue may be related to #15 because the problem is caused by trait objects. I guess something like
Box<G> where G: Generator
fixes it. Or some way to supportBox<Future + Send>
?Build log:
The text was updated successfully, but these errors were encountered: