1
- // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- #![ allow( missing_docs) ]
12
- #![ unstable( feature = "raw" , issue = "27751" ) ]
13
-
14
- //! Contains struct definitions for the layout of compiler built-in types.
15
- //!
16
- //! They can be used as targets of transmutes in unsafe code for manipulating
17
- //! the raw representations directly.
18
- //!
19
- //! Their definition should always match the ABI defined in `rustc::back::abi`.
11
+ //! Asynchronous values.
20
12
21
13
use core:: cell:: Cell ;
22
- use core:: future:: Future ;
23
14
use core:: marker:: Unpin ;
24
15
use core:: mem:: PinMut ;
25
16
use core:: option:: Option ;
26
17
use core:: ptr:: NonNull ;
27
18
use core:: task:: { self , Poll } ;
28
19
use core:: ops:: { Drop , Generator , GeneratorState } ;
29
20
30
- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
31
- pub use core:: raw :: * ;
21
+ #[ doc ( inline ) ]
22
+ pub use core:: future :: * ;
32
23
33
24
/// Wrap a future in a generator.
34
25
///
@@ -52,7 +43,7 @@ impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
52
43
impl < T : Generator < Yield = ( ) > > Future for GenFuture < T > {
53
44
type Output = T :: Return ;
54
45
fn poll ( self : PinMut < Self > , cx : & mut task:: Context ) -> Poll < Self :: Output > {
55
- with_set_cx ( cx, || match unsafe { PinMut :: get_mut ( self ) . 0 . resume ( ) } {
46
+ set_task_cx ( cx, || match unsafe { PinMut :: get_mut ( self ) . 0 . resume ( ) } {
56
47
GeneratorState :: Yielded ( ( ) ) => Poll :: Pending ,
57
48
GeneratorState :: Complete ( x) => Poll :: Ready ( x) ,
58
49
} )
@@ -74,7 +65,8 @@ impl Drop for SetOnDrop {
74
65
}
75
66
76
67
#[ unstable( feature = "gen_future" , issue = "50547" ) ]
77
- pub fn with_set_cx < F , R > ( cx : & mut task:: Context , f : F ) -> R
68
+ /// Sets the thread-local task context used by async/await futures.
69
+ pub fn set_task_cx < F , R > ( cx : & mut task:: Context , f : F ) -> R
78
70
where
79
71
F : FnOnce ( ) -> R
80
72
{
90
82
}
91
83
92
84
#[ unstable( feature = "gen_future" , issue = "50547" ) ]
93
- pub fn with_get_cx < F , R > ( f : F ) -> R
85
+ /// Retrieves the thread-local task context used by async/await futures.
86
+ ///
87
+ /// Panics if no task has been set or if the task context has already been
88
+ /// retrived by a surrounding call to get_task_cx.
89
+ pub fn get_task_cx < F , R > ( f : F ) -> R
94
90
where
95
91
F : FnOnce ( & mut task:: Context ) -> R
96
92
{
0 commit comments