runtime/backlog/config.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! How a table is made and configured: the window its callers block for
7//! before a command is handed to the background
8//! (`crates/runtime/spec/Backlog.lean` §8-28), where a command's output
9//! goes while it is inside that window (the same part, §8-28-3), and what
10//! shares every run it starts asks for
11//! (`crates/runtime/spec/Tools/Exec.lean` D29). The table itself, what it
12//! carries and how it ends, is the module above.
13
14use super::{Backlog, PollBudget, Scratch, Shares, Sink};
15
16impl Backlog {
17 #[must_use]
18 pub fn new() -> Backlog {
19 Backlog::default()
20 }
21
22 /// A table whose callers block for this window before a command is
23 /// handed to the background.
24 #[must_use]
25 pub fn with_window(window: PollBudget) -> Backlog {
26 Backlog {
27 table: std::sync::Arc::default(),
28 scratch: Scratch::open(),
29 window,
30 sink: None,
31 shares: Shares::Unset,
32 }
33 }
34
35 /// The same table, handing what a command writes to `sink` while
36 /// the command is still inside its window (`crates/runtime/spec/Backlog.lean` §8-28-3).
37 #[must_use]
38 pub fn with_sink(self, sink: Sink) -> Backlog {
39 Backlog {
40 sink: Some(sink),
41 ..self
42 }
43 }
44}