1
1
#![ feature( futures_api, arbitrary_self_types, pin) ]
2
2
3
- extern crate futures;
4
-
3
+ use futures:: channel:: oneshot:: { self , Sender } ;
4
+ use futures:: executor:: block_on;
5
+ use futures:: future:: { Future , FutureExt , poll_fn} ;
6
+ use futures:: task:: { self , Poll } ;
5
7
use std:: mem:: PinMut ;
6
8
use std:: sync:: mpsc;
7
9
use std:: thread;
8
10
9
- use futures:: future:: poll_fn;
10
- use futures:: prelude:: * ;
11
- use futures:: task;
12
- use futures:: channel:: oneshot:: * ;
13
- use futures:: executor:: block_on;
14
-
15
11
#[ test]
16
12
fn smoke_poll ( ) {
17
- let ( mut tx, rx) = channel :: < u32 > ( ) ;
13
+ let ( mut tx, rx) = oneshot :: channel :: < u32 > ( ) ;
18
14
let mut rx = Some ( rx) ;
19
15
let f = poll_fn ( |cx| {
20
16
assert ! ( tx. poll_cancel( cx) . is_pending( ) ) ;
@@ -30,7 +26,7 @@ fn smoke_poll() {
30
26
31
27
#[ test]
32
28
fn cancel_notifies ( ) {
33
- let ( tx, rx) = channel :: < u32 > ( ) ;
29
+ let ( tx, rx) = oneshot :: channel :: < u32 > ( ) ;
34
30
35
31
let t = thread:: spawn ( || {
36
32
block_on ( WaitForCancel { tx : tx } ) ;
@@ -62,7 +58,7 @@ fn cancel_lots() {
62
58
} ) ;
63
59
64
60
for _ in 0 ..20000 {
65
- let ( otx, orx) = channel :: < u32 > ( ) ;
61
+ let ( otx, orx) = oneshot :: channel :: < u32 > ( ) ;
66
62
let ( tx2, rx2) = mpsc:: channel ( ) ;
67
63
tx. send ( ( otx, tx2) ) . unwrap ( ) ;
68
64
drop ( orx) ;
@@ -75,7 +71,7 @@ fn cancel_lots() {
75
71
76
72
#[ test]
77
73
fn close ( ) {
78
- let ( mut tx, mut rx) = channel :: < u32 > ( ) ;
74
+ let ( mut tx, mut rx) = oneshot :: channel :: < u32 > ( ) ;
79
75
rx. close ( ) ;
80
76
block_on ( poll_fn ( |cx| {
81
77
match rx. poll_unpin ( cx) {
@@ -89,7 +85,7 @@ fn close() {
89
85
90
86
#[ test]
91
87
fn close_wakes ( ) {
92
- let ( tx, mut rx) = channel :: < u32 > ( ) ;
88
+ let ( tx, mut rx) = oneshot :: channel :: < u32 > ( ) ;
93
89
let ( tx2, rx2) = mpsc:: channel ( ) ;
94
90
let t = thread:: spawn ( move || {
95
91
rx. close ( ) ;
@@ -102,7 +98,7 @@ fn close_wakes() {
102
98
103
99
#[ test]
104
100
fn is_canceled ( ) {
105
- let ( tx, rx) = channel :: < u32 > ( ) ;
101
+ let ( tx, rx) = oneshot :: channel :: < u32 > ( ) ;
106
102
assert ! ( !tx. is_canceled( ) ) ;
107
103
drop ( rx) ;
108
104
assert ! ( tx. is_canceled( ) ) ;
@@ -118,7 +114,7 @@ fn cancel_sends() {
118
114
} ) ;
119
115
120
116
for _ in 0 ..20000 {
121
- let ( otx, mut orx) = channel :: < u32 > ( ) ;
117
+ let ( otx, mut orx) = oneshot :: channel :: < u32 > ( ) ;
122
118
tx. send ( otx) . unwrap ( ) ;
123
119
124
120
orx. close ( ) ;
0 commit comments