#[inline]
pub(super) fn publish_owner_after_waiter_detach<S, D, T, E>(
state: &mut S,
detach_waiter: impl FnOnce(&mut S) -> Result<D, E>,
publish_owner: impl FnOnce(&mut S, &D) -> Result<T, E>,
restore_waiter: impl FnOnce(&mut S, D),
) -> Result<(D, T), E> {
let detached = detach_waiter(state)?;
match publish_owner(state, &detached) {
Ok(published) => Ok((detached, published)),
Err(error) => {
restore_waiter(state, detached);
Err(error)
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(super) enum PiOwnerRqAccountingPath {
Running,
QueuedClassDequeue,
Inactive,
}
#[inline]
pub(super) fn owner_rq_needs_current_settlement<C: Eq>(
path: PiOwnerRqAccountingPath,
owner_accounting_class: Option<C>,
current_accounting_class: Option<C>,
) -> bool {
match path {
PiOwnerRqAccountingPath::Running => true,
PiOwnerRqAccountingPath::QueuedClassDequeue => {
owner_accounting_class.is_some() && owner_accounting_class == current_accounting_class
}
PiOwnerRqAccountingPath::Inactive => false,
}
}