Skip to content

Commit bbae91b

Browse files
committed
Add SubmitArgs::min_wait_usec setter
1 parent bc5c293 commit bbae91b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ impl Parameters {
597597
self.0.features & sys::IORING_FEAT_RECVSEND_BUNDLE != 0
598598
}
599599

600+
/// If this flag is set, applications can use the
601+
/// [`SubmitArgs::min_wait_usec`](types::SubmitArgs::min_wait_usec) method to specify a timeout
602+
/// after which the kernel will return as soon as a single completion is received instead of
603+
/// waiting for the minimum specified by the application. Available since kernel 6.12.
604+
pub fn is_feature_min_timeout(&self) -> bool {
605+
self.0.features & sys::IORING_FEAT_MIN_TIMEOUT != 0
606+
}
607+
600608
/// The number of submission queue entries allocated.
601609
pub fn sq_entries(&self) -> u32 {
602610
self.0.sq_entries

src/types.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,27 @@ impl<'prev, 'now> SubmitArgs<'prev, 'now> {
262262
}
263263
}
264264

265+
/// Sets a timeout in microseconds to start waiting for a minimum of a single completion.
266+
///
267+
/// Once the timeout expires, the kernel will return when a single completion has been received
268+
/// instead of waiting for the minimum amount of completions specified by the `want` parameter
269+
/// in the call to [`Submitter::submit_and_wait`](crate::Submitter::submit_and_wait) or
270+
/// [`Submitter::submit_with_args`](crate::Submitter::submit_with_args).
271+
///
272+
/// Available since 6.12. Use the
273+
/// [`Parameters::is_feature_min_timeout`](crate::Parameters::is_feature_min_timeout) method to
274+
/// check for availability.
275+
#[inline]
276+
pub fn min_wait_usec<'new>(mut self, min_wait_usec: u32) -> SubmitArgs<'now, 'new> {
277+
self.args.min_wait_usec = min_wait_usec;
278+
279+
SubmitArgs {
280+
args: self.args,
281+
prev: self.now,
282+
now: PhantomData,
283+
}
284+
}
285+
265286
#[inline]
266287
pub fn timespec<'new>(mut self, timespec: &'new Timespec) -> SubmitArgs<'now, 'new> {
267288
self.args.ts = cast_ptr(timespec) as _;

0 commit comments

Comments
 (0)