1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! How a reserved capacity slot becomes a tracked one.
//!
//! Split out of `heartbeat.rs` because it is a coherent decision with its own
//! reasoning — who owns the slot, and what happens to it in each case — and
//! because that file is over the size cap and may not grow.
//!
//! The whole surface is one function, and it exists because the transfer used
//! to be two acts under two registry locks. Between them a worker's `in_flight`
//! read one higher than the work it was holding, and a concurrent selection
//! landing in that window was refused a slot the worker demonstrably had:
//! measured at `in_flight = 5` on a worker advertising 4, on a fan sized exactly
//! to its pool, where the margin is zero and one collision is enough.
use crateServerError;
use crateConnectedWorkerRegistry;
use crate;
/// Settle the capacity slot for a dispatch that has just been tracked.
///
/// `first_tracking` is whether the tracker's insert actually added an entry, and
/// it is what decides ownership in both arms: the count must rise exactly once
/// per tracked dispatch, however many times that dispatch is tracked.
///
/// # Errors
///
/// Returns [`ServerError::LockPoisoned`] if the registry lock is poisoned while
/// raising the count for an unreserved dispatch.
pub