@@ -32,6 +32,9 @@ thread_local! {
3232scoped_thread_local ! ( pub ( crate ) static CURRENT : Context ) ;
3333
3434pub ( crate ) struct Context {
35+ /// Owned task set and local run queue
36+ pub ( crate ) tasks : TaskQueue ,
37+
3538 /// Thread id(not the kernel thread id but a generated unique number)
3639 pub ( crate ) thread_id : usize ,
3740
@@ -45,8 +48,6 @@ pub(crate) struct Context {
4548 pub ( crate ) waker_sender_cache :
4649 std:: cell:: RefCell < fxhash:: FxHashMap < usize , flume:: Sender < std:: task:: Waker > > > ,
4750
48- /// Owned task set and local run queue
49- pub ( crate ) tasks : TaskQueue ,
5051 /// Time Handle
5152 pub ( crate ) time_handle : Option < TimeHandle > ,
5253
@@ -95,10 +96,7 @@ impl Context {
9596 let w = v. clone ( ) ;
9697 self . unpark_cache . borrow_mut ( ) . insert ( id, w) ;
9798 v. unpark ( ) ;
98- return ;
9999 }
100-
101- panic ! ( "thread to unpark has not been registered" ) ;
102100 }
103101
104102 #[ allow( unused) ]
@@ -114,20 +112,21 @@ impl Context {
114112 // Write back to local cache
115113 let _ = s. send ( w) ;
116114 self . waker_sender_cache . borrow_mut ( ) . insert ( id, s) ;
117- return ;
118115 }
119-
120- panic ! ( "sender has not been registered" ) ;
121116 }
122117}
123118
124119/// Monoio runtime
125120pub struct Runtime < D > {
126- pub ( crate ) driver : D ,
127121 pub ( crate ) context : Context ,
122+ pub ( crate ) driver : D ,
128123}
129124
130125impl < D > Runtime < D > {
126+ pub ( crate ) fn new ( context : Context , driver : D ) -> Self {
127+ Self { context, driver }
128+ }
129+
131130 /// Block on
132131 pub fn block_on < F > ( & mut self , future : F ) -> F :: Output
133132 where
0 commit comments