mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 14:09:13 +00:00
In-process locking.
This commit is contained in:
61
vfs_lock_debug.go
Normal file
61
vfs_lock_debug.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package sqlite3
|
||||
|
||||
const assert = true
|
||||
|
||||
type vfsDebugLocker struct {
|
||||
state uint32
|
||||
}
|
||||
|
||||
var _ vfsLocker = &vfsDebugLocker{}
|
||||
|
||||
func (l *vfsDebugLocker) LockState() uint32 {
|
||||
return l.state
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) LockShared() uint32 {
|
||||
if assert && !(l.state == _NO_LOCK) {
|
||||
panic(assertErr + " [wz9dcw]")
|
||||
}
|
||||
l.state = _SHARED_LOCK
|
||||
return _OK
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) LockReserved() uint32 {
|
||||
if assert && !(l.state == _SHARED_LOCK) {
|
||||
panic(assertErr + " [m9hcil]")
|
||||
}
|
||||
l.state = _RESERVED_LOCK
|
||||
return _OK
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) LockPending() uint32 {
|
||||
if assert && !(l.state == _SHARED_LOCK || l.state == _RESERVED_LOCK) {
|
||||
panic(assertErr + " [wx8nk2]")
|
||||
}
|
||||
l.state = _PENDING_LOCK
|
||||
return _OK
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) LockExclusive() uint32 {
|
||||
if assert && !(l.state == _PENDING_LOCK) {
|
||||
panic(assertErr + " [84nbax]")
|
||||
}
|
||||
l.state = _EXCLUSIVE_LOCK
|
||||
return _OK
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) DowngradeLock() uint32 {
|
||||
if assert && !(l.state > _SHARED_LOCK) {
|
||||
panic(assertErr + " [je31i3]")
|
||||
}
|
||||
l.state = _SHARED_LOCK
|
||||
return _OK
|
||||
}
|
||||
|
||||
func (l *vfsDebugLocker) ReleaseLock() uint32 {
|
||||
if assert && !(l.state > _NO_LOCK) {
|
||||
panic(assertErr + " [m6e9w5]")
|
||||
}
|
||||
l.state = _NO_LOCK
|
||||
return _OK
|
||||
}
|
||||
Reference in New Issue
Block a user