pub struct ReadTxn<'db, F: FileBackend> { /* private fields */ }Expand description
A read transaction.
Construct via ReadTxn::begin. Holds:
- A
ReaderSnapshotpinning the WAL end-LSN at construction. - An optional cross-process
READER_LOCKbyte (shared with other readers but not exclusive with writers — seedocs/format.md§ File locking).
Reads inside a ReadTxn see a consistent snapshot of the
database; pending writes from a concurrent WriteTxn and frames
committed AFTER ReadTxn::begin are invisible.
Implementations§
Source§impl<'db, F: FileBackend> ReadTxn<'db, F>
impl<'db, F: FileBackend> ReadTxn<'db, F>
Sourcepub fn begin(env: &'db TxnEnv<F>) -> Result<Self>
pub fn begin(env: &'db TxnEnv<F>) -> Result<Self>
Begin a new read transaction.
Acquires a cross-process reader-lock slot (if env.lock_file
is Some) with the env’s default busy timeout, then takes a
ReaderSnapshot from the pager. Readers do not contend
with each other (31 shared slots) and do not contend with
writers on the byte-range layer.
§Errors
Error::BusywithLockKind::Readeron lock timeout.Error::Ioon lock or pager syscall failure.
Sourcepub fn begin_with_timeout(
env: &'db TxnEnv<F>,
timeout: Duration,
) -> Result<Self>
pub fn begin_with_timeout( env: &'db TxnEnv<F>, timeout: Duration, ) -> Result<Self>
Sourcepub fn pinned_lsn(&self) -> Lsn
pub fn pinned_lsn(&self) -> Lsn
LSN this txn’s snapshot pinned. Diagnostic-only.
Sourcepub fn snapshot(&self) -> &ReaderSnapshot<F>
pub fn snapshot(&self) -> &ReaderSnapshot<F>
Access the underlying snapshot. Used by obj::Db (M6 issue
#47) to dispatch typed reads on a read txn.
Trait Implementations§
Auto Trait Implementations§
impl<'db, F> Freeze for ReadTxn<'db, F>
impl<'db, F> RefUnwindSafe for ReadTxn<'db, F>
impl<'db, F> Send for ReadTxn<'db, F>where
F: Send,
impl<'db, F> Sync for ReadTxn<'db, F>where
F: Send,
impl<'db, F> Unpin for ReadTxn<'db, F>
impl<'db, F> UnsafeUnpin for ReadTxn<'db, F>
impl<'db, F> UnwindSafe for ReadTxn<'db, F>
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
Mutably borrows from an owned value. Read more