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