@@ -6,7 +6,6 @@ use std::{
66 pin:: Pin ,
77 ptr:: { null, null_mut} ,
88 task:: { Context , Poll , Waker } ,
9- time:: Duration ,
109} ;
1110
1211use compio:: driver:: AsRawFd ;
@@ -80,7 +79,7 @@ impl Default for FutureState {
8079}
8180
8281pub struct Runtime {
83- runtime : compio :: runtime :: Runtime ,
82+ runtime : winio_pollable :: Runtime ,
8483 d2d1 : OnceCell < ID2D1Factory > ,
8584 registry : RefCell < HashMap < ( HWND , u32 ) , Slab < FutureState > > > ,
8685}
@@ -97,7 +96,7 @@ impl Runtime {
9796 init_dark ( ) ;
9897 }
9998
100- let runtime = compio :: runtime :: Runtime :: new ( ) . unwrap ( ) ;
99+ let runtime = winio_pollable :: Runtime :: new ( ) . unwrap ( ) ;
101100
102101 Self {
103102 runtime,
@@ -118,25 +117,7 @@ impl Runtime {
118117
119118 pub fn block_on < F : Future > ( & self , future : F ) -> F :: Output {
120119 self . enter ( || {
121- let mut result = None ;
122- unsafe {
123- self . runtime
124- . spawn_unchecked ( async { result = Some ( future. await ) } )
125- }
126- . detach ( ) ;
127- loop {
128- self . runtime . poll_with ( Some ( Duration :: ZERO ) ) ;
129-
130- let remaining_tasks = self . runtime . run ( ) ;
131- if let Some ( result) = result. take ( ) {
132- break result;
133- }
134-
135- let timeout = if remaining_tasks {
136- Some ( Duration :: ZERO )
137- } else {
138- self . runtime . current_timeout ( )
139- } ;
120+ self . runtime . block_on ( future, |timeout| {
140121 let timeout = match timeout {
141122 Some ( timeout) => timeout. as_millis ( ) as u32 ,
142123 None => INFINITE ,
@@ -171,7 +152,7 @@ impl Runtime {
171152 break ;
172153 }
173154 }
174- }
155+ } )
175156 } )
176157 }
177158
0 commit comments