mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 16:35:21 +00:00
improve snapshot docs
Using two snapshots from the same thread isn't really very easy to do, so we don't have to warn about that really (it's really nested use of snapshots that's a problem, and to do that you have to use thread-locals or something just to get the snapshot *into* the database -- at that point, something is really going wrong)).
This commit is contained in:
parent
a8ca57c06d
commit
5a88871b9a
1 changed files with 12 additions and 3 deletions
15
src/lib.rs
15
src/lib.rs
|
@ -288,11 +288,20 @@ pub trait ParallelDatabase: Database + Send {
|
|||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// It is not permitted to create a snapshot from inside of a
|
||||
/// query. Attepting to do so will panic.
|
||||
///
|
||||
/// # Deadlock warning
|
||||
///
|
||||
/// This second handle is intended to be used from a separate
|
||||
/// thread. Using two database handles from the **same thread**
|
||||
/// can lead to deadlock.
|
||||
/// The intended pattern for snapshots is that, once created, they
|
||||
/// are sent to another thread and used from there. As such, the
|
||||
/// `snapshot` acquires a "read lock" on the database --
|
||||
/// therefore, so long as the `snapshot` is not dropped, any
|
||||
/// attempt to `set` a value in the database will block. If the
|
||||
/// `snapshot` is owned by the same thread that is attempting to
|
||||
/// `set`, this will cause a problem.
|
||||
fn snapshot(&self) -> Snapshot<Self>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue