Skip to main content

sim_storage_port/
commit.rs

1// SPDX-License-Identifier: MPL-2.0
2// This Source Code Form is subject to the terms of the Mozilla Public
3// License, v. 2.0. If a copy of the MPL was not distributed with this
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
6//! Borrowed continuation for an adapter-owned commit boundary.
7
8/// A short action invoked after commit, while competing commits remain excluded.
9///
10/// The action runs synchronously on the admitting thread. It must not acquire
11/// resources, wait for payload work, or mutate the same admission domain. Reads
12/// are permitted. Its domain-specific result belongs to the caller; returning
13/// from this method is not an acknowledgement of any external effect.
14///
15/// A native effect must be resolved locally under this boundary. Queueing an
16/// asynchronous request and returning does not extend the exclusion to that
17/// request. Failure or caller loss after commit requires reconciliation, not
18/// unconditional repetition of the action.
19pub trait CommitAction {
20    /// Acts once after this invocation's new commit, before releasing exclusion.
21    fn after_commit(&mut self);
22}
23
24impl<F: FnMut()> CommitAction for F {
25    fn after_commit(&mut self) {
26        self();
27    }
28}