File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ impl Driver {
82
82
instrument ! ( compio_log:: Level :: TRACE , "new" , ?builder) ;
83
83
trace ! ( "new iour driver" ) ;
84
84
let notifier = Notifier :: new ( ) ?;
85
- let mut inner = IoUring :: builder ( ) . build ( builder. capacity ) ?;
85
+ let mut io_uring_builder = IoUring :: builder ( ) ;
86
+ if let Some ( sqpoll_idle) = builder. sqpoll_idle {
87
+ io_uring_builder. setup_sqpoll ( sqpoll_idle. as_millis ( ) as _ ) ;
88
+ }
89
+ let mut inner = io_uring_builder. build ( builder. capacity ) ?;
86
90
#[ allow( clippy:: useless_conversion) ]
87
91
unsafe {
88
92
inner
Original file line number Diff line number Diff line change @@ -401,6 +401,7 @@ impl ThreadPoolBuilder {
401
401
pub struct ProactorBuilder {
402
402
capacity : u32 ,
403
403
pool_builder : ThreadPoolBuilder ,
404
+ sqpoll_idle : Option < Duration > ,
404
405
}
405
406
406
407
impl Default for ProactorBuilder {
@@ -415,6 +416,7 @@ impl ProactorBuilder {
415
416
Self {
416
417
capacity : 1024 ,
417
418
pool_builder : ThreadPoolBuilder :: new ( ) ,
419
+ sqpoll_idle : None ,
418
420
}
419
421
}
420
422
@@ -465,6 +467,19 @@ impl ProactorBuilder {
465
467
self . pool_builder . create_or_reuse ( )
466
468
}
467
469
470
+ /// Set `io-uring` sqpoll idle milliseconds, when `sqpoll_idle` is set,
471
+ /// io-uring sqpoll feature will be enabled
472
+ ///
473
+ /// # Notes
474
+ ///
475
+ /// - Only effective when the `io-uring` feature is enabled
476
+ /// - `idle` must >= 1ms, otherwise will set sqpoll idle 0ms
477
+ /// - `idle` will be rounded down
478
+ pub fn sqpoll_idle ( & mut self , idle : Duration ) -> & mut Self {
479
+ self . sqpoll_idle = Some ( idle) ;
480
+ self
481
+ }
482
+
468
483
/// Build the [`Proactor`].
469
484
pub fn build ( & self ) -> io:: Result < Proactor > {
470
485
Proactor :: with_builder ( self )
Original file line number Diff line number Diff line change 17
17
#![ cfg_attr( feature = "once_cell_try" , feature( once_cell_try) ) ]
18
18
#![ cfg_attr( feature = "lazy_cell" , feature( lazy_cell) ) ]
19
19
#![ warn( missing_docs) ]
20
+ #![ allow( stable_features) ]
20
21
21
22
#[ cfg( windows) ]
22
23
pub mod windows;
You can’t perform that action at this time.
0 commit comments