File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,20 +38,25 @@ pub(crate) struct Driver {
3838impl Driver {
3939 /// Create a new fusion driver with given number of entries
4040 pub fn new ( builder : & ProactorBuilder ) -> io:: Result < Self > {
41- match DriverType :: suggest ( ) {
41+ let ( ty, fallback) = match & builder. driver_type {
42+ Some ( t) => ( * t, false ) ,
43+ None => ( DriverType :: suggest ( ) , true ) ,
44+ } ;
45+ match ty {
4246 DriverType :: Poll => Ok ( Self {
4347 fuse : FuseDriver :: Poll ( poll:: Driver :: new ( builder) ?) ,
4448 } ) ,
4549 DriverType :: IoUring => match iour:: Driver :: new ( builder) {
4650 Ok ( driver) => Ok ( Self {
4751 fuse : FuseDriver :: IoUring ( driver) ,
4852 } ) ,
49- Err ( _e) => {
53+ Err ( _e) if fallback => {
5054 warn ! ( "Fail to create io-uring driver: {_e:?}, fallback to polling driver." ) ;
5155 Ok ( Self {
5256 fuse : FuseDriver :: Poll ( poll:: Driver :: new ( builder) ?) ,
5357 } )
5458 }
59+ Err ( e) => Err ( e) ,
5560 } ,
5661 _ => unreachable ! ( "Fuse driver will only be enabled on linux" ) ,
5762 }
Original file line number Diff line number Diff line change @@ -458,6 +458,7 @@ pub struct ProactorBuilder {
458458 coop_taskrun : bool ,
459459 taskrun_flag : bool ,
460460 eventfd : Option < RawFd > ,
461+ driver_type : Option < DriverType > ,
461462}
462463
463464// Safety: `RawFd` is thread safe.
@@ -480,6 +481,7 @@ impl ProactorBuilder {
480481 coop_taskrun : false ,
481482 taskrun_flag : false ,
482483 eventfd : None ,
484+ driver_type : None ,
483485 }
484486 }
485487
@@ -585,6 +587,13 @@ impl ProactorBuilder {
585587 self
586588 }
587589
590+ /// Force a driver type to use. It is ignored if the fusion driver is
591+ /// disabled.
592+ pub fn driver_type ( & mut self , t : DriverType ) -> & mut Self {
593+ self . driver_type = Some ( t) ;
594+ self
595+ }
596+
588597 /// Build the [`Proactor`].
589598 pub fn build ( & self ) -> io:: Result < Proactor > {
590599 Proactor :: with_builder ( self )
You can’t perform that action at this time.
0 commit comments