From df52bd0803e5062c92eb947ef63fdf0dd74c5753 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 18 May 2015 13:45:02 -0600 Subject: Add test case inline documentation. --- db.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'db.go') diff --git a/db.go b/db.go index d1b722a..6592b38 100644 --- a/db.go +++ b/db.go @@ -102,10 +102,12 @@ type DB struct { statlock sync.RWMutex // Protects stats access. ops struct { - writeAt func(b []byte, off int64) (n int, err error) + writeAt func(b []byte, off int64) (n int, err error) } - readOnly bool // Read only mode. Update()/Begin(true) would return ErrDatabaseReadOnly immediately. + // Read only mode. + // When true, Update() and Begin(true) return ErrDatabaseReadOnly immediately. + readOnly bool } // Path returns the path to currently open database file. @@ -440,9 +442,11 @@ func (db *DB) beginTx() (*Tx, error) { } func (db *DB) beginRWTx() (*Tx, error) { + // If the database was opened with Options.ReadOnly, return an error. if db.readOnly { return nil, ErrDatabaseReadOnly } + // Obtain writer lock. This is released by the transaction when it closes. // This enforces only one writer transaction at a time. db.rwlock.Lock() -- cgit v1.2.3