mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
Swap Handle/Pinned
* Handle -> Remote * Pinned -> Handle All APIs now take a `&Handle` by default and in general can return an immediate `io::Result` instead of an `IoFuture`. This reflects how most usage will likely be done through handles rather than remotes, and also all previous functionality can be recovered with a `oneshot` plus `Remote::spawn`. Closes #15
This commit is contained in:
+5
-5
@@ -12,11 +12,11 @@ fn simple() {
|
||||
|
||||
let (tx1, rx1) = futures::oneshot();
|
||||
let (tx2, rx2) = futures::oneshot();
|
||||
lp.pin().spawn(futures::lazy(|| {
|
||||
lp.handle().spawn(futures::lazy(|| {
|
||||
tx1.complete(1);
|
||||
Ok(())
|
||||
}));
|
||||
lp.handle().spawn(|_| {
|
||||
lp.remote().spawn(|_| {
|
||||
futures::lazy(|| {
|
||||
tx2.complete(2);
|
||||
Ok(())
|
||||
@@ -33,10 +33,10 @@ fn spawn_in_poll() {
|
||||
|
||||
let (tx1, rx1) = futures::oneshot();
|
||||
let (tx2, rx2) = futures::oneshot();
|
||||
let handle = lp.handle();
|
||||
lp.pin().spawn(futures::lazy(move || {
|
||||
let remote = lp.remote();
|
||||
lp.handle().spawn(futures::lazy(move || {
|
||||
tx1.complete(1);
|
||||
handle.spawn(|_| {
|
||||
remote.spawn(|_| {
|
||||
futures::lazy(|| {
|
||||
tx2.complete(2);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user