1- // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
22// file at the top-level directory of this distribution and at
33// http://rust-lang.org/COPYRIGHT.
44//
88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
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.
2012
2113use core:: cell:: Cell ;
22- use core:: future:: Future ;
2314use core:: marker:: Unpin ;
2415use core:: mem:: PinMut ;
2516use core:: option:: Option ;
2617use core:: ptr:: NonNull ;
2718use core:: task:: { self , Poll } ;
2819use core:: ops:: { Drop , Generator , GeneratorState } ;
2920
30- #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
31- pub use core:: raw :: * ;
21+ #[ doc ( inline ) ]
22+ pub use core:: future :: * ;
3223
3324/// Wrap a future in a generator.
3425///
@@ -52,7 +43,7 @@ impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
5243impl < T : Generator < Yield = ( ) > > Future for GenFuture < T > {
5344 type Output = T :: Return ;
5445 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 ( ) } {
5647 GeneratorState :: Yielded ( ( ) ) => Poll :: Pending ,
5748 GeneratorState :: Complete ( x) => Poll :: Ready ( x) ,
5849 } )
@@ -74,7 +65,8 @@ impl Drop for SetOnDrop {
7465}
7566
7667#[ 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
7870where
7971 F : FnOnce ( ) -> R
8072{
9082}
9183
9284#[ 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
9490where
9591 F : FnOnce ( & mut task:: Context ) -> R
9692{
0 commit comments