File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ pub mod fs;
79
79
pub mod net;
80
80
81
81
pub use runtime:: spawn;
82
+ pub use runtime:: Runtime ;
82
83
83
84
use std:: future:: Future ;
84
85
@@ -140,7 +141,7 @@ use std::future::Future;
140
141
/// }
141
142
/// ```
142
143
pub fn start < F : Future > ( future : F ) -> F :: Output {
143
- let mut rt = runtime:: Runtime :: new ( & builder ( ) ) . unwrap ( ) ;
144
+ let rt = runtime:: Runtime :: new ( & builder ( ) ) . unwrap ( ) ;
144
145
rt. block_on ( future)
145
146
}
146
147
@@ -225,7 +226,7 @@ impl Builder {
225
226
/// }
226
227
/// ```
227
228
pub fn start < F : Future > ( & self , future : F ) -> F :: Output {
228
- let mut rt = runtime:: Runtime :: new ( self ) . unwrap ( ) ;
229
+ let rt = runtime:: Runtime :: new ( self ) . unwrap ( ) ;
229
230
rt. block_on ( future)
230
231
}
231
232
}
Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ use std::io;
6
6
use tokio:: io:: unix:: AsyncFd ;
7
7
use tokio:: task:: LocalSet ;
8
8
9
- pub ( crate ) struct Runtime {
9
+ /// The Runtime executor
10
+ pub struct Runtime {
10
11
/// io-uring driver
11
12
driver : AsyncFd < Driver > ,
12
13
@@ -48,7 +49,8 @@ pub fn spawn<T: std::future::Future + 'static>(task: T) -> tokio::task::JoinHand
48
49
}
49
50
50
51
impl Runtime {
51
- pub ( crate ) fn new ( b : & crate :: Builder ) -> io:: Result < Runtime > {
52
+ /// Create a new tokio_uring runtime on the current thread
53
+ pub fn new ( b : & crate :: Builder ) -> io:: Result < Runtime > {
52
54
let rt = tokio:: runtime:: Builder :: new_current_thread ( )
53
55
. on_thread_park ( || {
54
56
CURRENT . with ( |x| {
@@ -68,7 +70,8 @@ impl Runtime {
68
70
Ok ( Runtime { driver, local, rt } )
69
71
}
70
72
71
- pub ( crate ) fn block_on < F > ( & mut self , future : F ) -> F :: Output
73
+ /// Runs a future to completion on the current runtime
74
+ pub fn block_on < F > ( & self , future : F ) -> F :: Output
72
75
where
73
76
F : Future ,
74
77
{
You can’t perform that action at this time.
0 commit comments