summaryrefslogtreecommitdiffstats
path: root/src/watch/upstream.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-20 23:39:07 +0000
committeraur-build <aur-build@localhost>2026-11-20 23:39:07 +0000
commitdebb8af0ef0e72048b9df5fed40071745ea40c6b (patch)
tree7cb37ad58cf8268b8e24530a384af95c8bd51b32 /src/watch/upstream.rs
parentc295510e2bb0ee61234536c832dad87a45977fc8 (diff)
downloadaur-build-debb8af0ef0e72048b9df5fed40071745ea40c6b.tar.gz
aur-build-debb8af0ef0e72048b9df5fed40071745ea40c6b.zip
sandbox,http,review,watch: keep six more test-only types out of the release build
Diffstat (limited to 'src/watch/upstream.rs')
-rw-r--r--src/watch/upstream.rs43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs
index c3e4954..888a5ed 100644
--- a/src/watch/upstream.rs
+++ b/src/watch/upstream.rs
@@ -143,25 +143,42 @@ static RUNNING: AtomicUsize = AtomicUsize::new(0);
static SLOT_FREE: Condvar = Condvar::new();
static SLOT_LOCK: Mutex<()> = Mutex::new(());
-pub struct StageBSlot(());
+/// The real definition. The module is private, so this `pub`
+/// is not a nameable path from outside; the alias below is the
+/// only way to reach it, and the alias is what carries the
+/// feature-conditional visibility.
+mod stage_b_slot {
+ pub struct StageBSlot(());
-impl StageBSlot {
- pub fn acquire(cap: usize) -> Self {
- let cap = cap.max(1);
- let guard = SLOT_LOCK.lock().unwrap_or_else(|e| e.into_inner());
- let mut guard = guard;
- loop {
- let n = RUNNING.load(Ordering::SeqCst);
- if n < cap {
- RUNNING.fetch_add(1, Ordering::SeqCst);
- drop(guard);
- return StageBSlot(());
+ impl StageBSlot {
+ pub fn acquire(cap: usize) -> Self {
+ let cap = cap.max(1);
+ let guard = SLOT_LOCK.lock().unwrap_or_else(|e| e.into_inner());
+ let mut guard = guard;
+ loop {
+ let n = RUNNING.load(Ordering::SeqCst);
+ if n < cap {
+ RUNNING.fetch_add(1, Ordering::SeqCst);
+ drop(guard);
+ return StageBSlot(());
+ }
+ guard = SLOT_FREE.wait(guard).unwrap_or_else(|e| e.into_inner());
}
- guard = SLOT_FREE.wait(guard).unwrap_or_else(|e| e.into_inner());
}
}
}
+/// The stage-B concurrency slot. The VCS test that asserts it needs a real mirror, so it cannot move into the module.
+///
+/// `pub` only under `test-support`. Production reaches the type
+/// through its own module and never names it from outside; the
+/// outside reader that needs the name is a test.
+#[cfg(feature = "test-support")]
+pub use stage_b_slot::StageBSlot;
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) use stage_b_slot::StageBSlot;
+
impl Drop for StageBSlot {
fn drop(&mut self) {
RUNNING.fetch_sub(1, Ordering::SeqCst);