async_txn/
read.rs

1use super::*;
2
3/// AsyncRtm is a read-only transaction manager.
4///
5/// It is created by calling [`AsyncTm::read`],
6/// the read transaction will automatically notify the transaction manager when it
7/// is dropped. So, the end user doesn't need to call any cleanup function, but must
8/// hold this struct in their final read transaction implementation.
9pub struct AsyncRtm<K, V, C, P, S>
10where
11  S: AsyncSpawner,
12{
13  pub(super) db: AsyncTm<K, V, C, P, S>,
14  pub(super) read_ts: u64,
15}
16
17impl<K, V, C, P, S> AsyncRtm<K, V, C, P, S>
18where
19  S: AsyncSpawner,
20{
21  /// Returns the version of this read transaction.
22  #[inline]
23  pub const fn version(&self) -> u64 {
24    self.read_ts
25  }
26}
27
28impl<K, V, C, P, S> Drop for AsyncRtm<K, V, C, P, S>
29where
30  S: AsyncSpawner,
31{
32  fn drop(&mut self) {
33    self.db.inner.done_read(self.read_ts)
34  }
35}