Use this type for fields in structs that are to store the Snapshot, typically behind an OwnShared.
Note that the resource itself is behind another OwnShared to allow it to be used without holding any kind of lock, hence
without blocking updates while it is used.
Refresh state forcefully by re-opening the resource. Note that open() returns None if the resource isn’t
present on disk, and that it’s critical that the modified time is obtained before opening the resource.
Assure that the resource in state is up-to-date by comparing the current_modification_time with the one we know in state
and by acting accordingly.
Returns the potentially updated/reloaded resource if it is still present on disk, which then represents a snapshot that is up-to-date
in that very moment, or None if the underlying file doesn’t exist.
Note that even though this is racy, each time a request is made there is a chance to see the actual state.
This method must only be called if the thread logically holds a read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget.
Locks this RwLock with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which
hold the lock. There may be other readers currently inside the lock when
this method returns.
Note that attempts to recursively acquire a read lock on a RwLock when
the current thread already holds one may result in a deadlock.
Returns an RAII guard which will release this thread’s shared access
once it is dropped.
Attempts to acquire this RwLock with shared read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
Attempts to lock this RwLock with exclusive write access.
If the lock could not be acquired at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the lock when
it is dropped.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard object alive, for example when
dealing with FFI.
This method must only be called if the current thread logically owns a
RwLockReadGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockWriteGuard object alive, for example when
dealing with FFI.
This method must only be called if the current thread logically owns a
RwLockWriteGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard or RwLockWriteGuard object
alive, for example when dealing with FFI.
You must ensure that there are no data races when dereferencing the
returned pointer, for example if the current thread logically owns a
RwLockReadGuard or RwLockWriteGuard but that guard has been discarded
using mem::forget.
Forcibly unlocks a read lock using a fair unlock protocol.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockReadGuard object alive, for example when
dealing with FFI.
This method must only be called if the current thread logically owns a
RwLockReadGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is read-unlocked when not read-locked.
Forcibly unlocks a write lock using a fair unlock protocol.
This is useful when combined with mem::forget to hold a lock without
the need to maintain a RwLockWriteGuard object alive, for example when
dealing with FFI.
This method must only be called if the current thread logically owns a
RwLockWriteGuard but that guard has be discarded using mem::forget.
Behavior is undefined if a rwlock is write-unlocked when not write-locked.
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Attempts to acquire this RwLock with exclusive write access until a
timeout is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
Attempts to acquire this RwLock with exclusive write access until a
timeout is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the exclusive access when it is dropped.
Locks this RwLock with shared read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers which
hold the lock. There may be other readers currently inside the lock when
this method returns.
Unlike read, this method is guaranteed to succeed without blocking if
another read lock is held at the time of the call. This allows a thread
to recursively lock a RwLock. However using this method can cause
writers to starve since readers no longer block if a writer is waiting
for the lock.
Returns an RAII guard which will release this thread’s shared access
once it is dropped.
Attempts to acquire this RwLock with shared read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
This method is guaranteed to succeed if another read lock is held at the
time of the call. See the documentation for read_recursive for details.
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
This method is guaranteed to succeed without blocking if another read
lock is held at the time of the call. See the documentation for
read_recursive for details.
Attempts to acquire this RwLock with shared read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
This method must only be called if the thread logically holds an upgradable read lock.
This function does not increment the read count of the lock. Calling this function when a
guard has already been produced is undefined behaviour unless the guard was forgotten
with mem::forget.
Locks this RwLock with upgradable read access, blocking the current thread
until it can be acquired.
The calling thread will be blocked until there are no more writers or other
upgradable reads which hold the lock. There may be other readers currently
inside the lock when this method returns.
Returns an RAII guard which will release this thread’s shared access
once it is dropped.
Attempts to acquire this RwLock with upgradable read access.
If the access could not be granted at this time, then None is returned.
Otherwise, an RAII guard is returned which will release the shared access
when it is dropped.
Attempts to acquire this RwLock with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.
Attempts to acquire this RwLock with upgradable read access until a timeout
is reached.
If the access could not be granted before the timeout expires, then
None is returned. Otherwise, an RAII guard is returned which will
release the shared access when it is dropped.