pub enum LockKind {
None,
Shared,
Reserved,
Pending,
Exclusive,
}
Expand description
The access an object is opened with.
Variants§
None
No locks are held. The database may be neither read nor written. Any internally cached data is considered suspect and subject to verification against the database file before being used. Other processes can read or write the database as their own locking states permit. This is the default state.
The database may be read but not written. Any number of processes can hold LockKind::Shared locks at the same time, hence there can be many simultaneous readers. But no other thread or process is allowed to write to the database file while one or more LockKind::Shared locks are active.
Reserved
A LockKind::Reserved lock means that the process is planning on writing to the database file at some point in the future but that it is currently just reading from the file. Only a single LockKind::Reserved lock may be active at one time, though multiple LockKind::Shared locks can coexist with a single LockKind::Reserved lock. LockKind::Reserved differs from LockKind::Pending in that new LockKind::Shared locks can be acquired while there is a LockKind::Reserved lock.
Pending
A LockKind::Pending lock means that the process holding the lock wants to write to the database as soon as possible and is just waiting on all current LockKind::Shared locks to clear so that it can get an LockKind::Exclusive lock. No new LockKind::Shared locks are permitted against the database if a LockKind::Pending lock is active, though existing LockKind::Shared locks are allowed to continue.
Exclusive
An LockKind::Exclusive lock is needed in order to write to the database file. Only one LockKind::Exclusive lock is allowed on the file and no other locks of any kind are allowed to coexist with an LockKind::Exclusive lock. In order to maximize concurrency, SQLite works to minimize the amount of time that LockKind::Exclusive locks are held.