pub struct DebouncedWriter { /* private fields */ }Expand description
Atomic, debounced single-file writer.
All writers in a process share one background I/O thread (see
module docs). Each writer is identified by an opaque WriterId;
dropping a writer synchronously flushes its pending payload before
returning.
Implementations§
Source§impl DebouncedWriter
impl DebouncedWriter
Sourcepub fn new(path: PathBuf, delay: Duration) -> Self
pub fn new(path: PathBuf, delay: Duration) -> Self
Create a writer that will atomically write to path, coalescing
rapid schedule bursts inside delay.
delay = Duration::ZERO makes every schedule flush on the
worker’s very next iteration — useful for tests.
Sourcepub fn flush_now(&self) -> Result<(), FlushError>
pub fn flush_now(&self) -> Result<(), FlushError>
Force any queued patches to disk synchronously. Returns Ok(()) if
there was nothing queued.
Sourcepub fn set_landed_sink(&self, sink: WriteLandedSink)
pub fn set_landed_sink(&self, sink: WriteLandedSink)
Register a sink for this writer’s successful-flush stamp (opt-in; a writer with none behaves exactly as today). May be called any time after construction — including after the writer has already flushed once, since the sink is only ever consulted on a future successful flush.
This is how a caller learns the real on-disk stamp resulting from
its own debounced write, without guessing: apply() schedules a
patch and returns before it lands, so only the worker thread — right
after the write actually succeeds — knows the resulting (mtime, len). See WindowStateService::reload_from_disk for the consumer
side (F11).