pub struct FileWriters { /* private fields */ }Expand description
Open write handles keyed by file id.
Handles are opened on the first chunk that arrives for a file rather than up front: a manifest may name a million files, and a million open descriptors is not a thing we can ask the OS for.
Implementations§
Source§impl FileWriters
impl FileWriters
pub fn new() -> Self
Sourcepub fn get_or_open<F>(&self, file_id: u32, make: F) -> Result<Arc<WriteHandle>>
pub fn get_or_open<F>(&self, file_id: u32, make: F) -> Result<Arc<WriteHandle>>
Fetch the handle for file_id, opening it with make if absent.
make runs at most once per file, even when every worker hits the
same file’s first chunk simultaneously. That is not just an efficiency
point: opening a destination preallocates it, so letting several racing
callers each open the same file reserved the file’s full size several
times over and could exhaust the disk on a large transfer.
The lock taken during make is per file, so opening one file never
blocks writers on another.
pub fn take(&self, file_id: u32) -> Option<Arc<WriteHandle>>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn discard_all(&self)
pub fn discard_all(&self)
Drop every handle, deleting partial files. Used on unrecoverable abort.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FileWriters
impl !RefUnwindSafe for FileWriters
impl !UnwindSafe for FileWriters
impl Send for FileWriters
impl Sync for FileWriters
impl Unpin for FileWriters
impl UnsafeUnpin for FileWriters
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more