pub struct FileBudget { /* private fields */ }Expand description
The installation’s places for open files, shared by every store its app opens. Cloning shares them. The app makes one when it starts, and each piece of work takes a lease of places from it (E1).
Implementations§
Source§impl FileBudget
impl FileBudget
Sourcepub fn new(size: NonZeroUsize) -> Self
pub fn new(size: NonZeroUsize) -> Self
A budget of size places, at most u32::MAX. The app makes one
with under_descriptor_limit; a test that needs a size makes it here.
Sourcepub fn under_descriptor_limit() -> Self
pub fn under_descriptor_limit() -> Self
A budget of an eighth of the process’s descriptor limit, at least 1:
32 places under a macOS app’s limit of 256, 128 under 1024. A
process with no limit counts as 10240, macOS’s OPEN_MAX, and so does
Windows, where the handles std::fs and SQLite open have no limit.
One place stands for at most 4 descriptors: the file it opens, or the cache files a stream’s reads in flight open (at most 3), and one file the work writes beside it. The places therefore take at most half the limit, and the other half holds what the budget doesn’t count: each open store’s database files, locks, sockets and the platform’s own descriptors. The limit is read once, here.
Sourcepub async fn lease(&self, count: usize) -> Result<FileLease, LeaseTooLarge>
pub async fn lease(&self, count: usize) -> Result<FileLease, LeaseTooLarge>
Take count places in one wait, behind every lease that began
waiting before. Call it only while holding no place of this budget:
a holder that waits here can wait forever. A count above the
budget’s size fails at once.
Sourcepub fn lease_blocking(&self, count: usize) -> Result<FileLease, LeaseTooLarge>
pub fn lease_blocking(&self, count: usize) -> Result<FileLease, LeaseTooLarge>
Self::lease, blocking this thread in the same line as the async
leases. Call it only off the async workers: on the blocking pool or a
thread of the caller’s own.
Sourcepub fn watch(&self) -> FileBudgetWatch
pub fn watch(&self) -> FileBudgetWatch
What a test reads of this budget’s use.