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
//! One `Mutex` per resolved snippet-validation session, keyed by *fingerprint* rather than by the
//! config session name it was reached through. Split out of `runner` under the repo's file-size
//! cap.
//!
//! Multiple session names can resolve to the same fingerprint: same `cwd`, manifest, env,
//! features (see `alef.toml`'s own `[workspace.docs.snippets.sessions.typescript]` comment on
//! aliasing `typescript` and `node` to the same package), which is also the same physical
//! workspace directory a batch validator writes scratch files into. Keying the lock by name
//! instead handed each alias its own `Mutex`, so two batch groups that both believed they held
//! "the" session lock wrote into the same `snippet_batch_N.ts` files concurrently. ~keep
use HashMap;
use Mutex;
/// Deduplicates on fingerprint, so two config names sharing one fingerprint end up pointing at the
/// identical `Mutex`.
pub
/// Resolves the `Mutex` a snippet's session actually shares with every other session aliased to
/// the same fingerprint. Looking this up by the session's *name* instead was the bug this module
/// exists to fix.
pub