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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//! Owner-thread-confined cell: shared-Sync wrapper around an `UnsafeCell`.
//!
//! The cell is `Sync` so it can live inside a struct that is itself shared
//! across threads, but every access goes through `unsafe fn with`. The
//! `unsafe` caller asserts that the call happens on the cell's logical
//! "owner thread"; concurrent access is undefined behavior.
//!
//! Used by [`ChunkProvider`](super::ChunkProvider) to hold the local-chunk
//! cache head and local high-water mark — both touched exclusively by the
//! arena's owning thread, even though the provider itself is `Sync`.
use UnsafeCell;
/// `UnsafeCell<T>` with a manually-asserted owner-thread invariant.
pub
// SAFETY: All access is through `with`, whose `unsafe` contract requires the
// caller to be on the cell's owner thread. We make no claim about concurrent
// access — that obligation is fully delegated to the caller.
unsafe