diff options
| author | Ben Johnson <benbjohnson@yahoo.com> | 2015-05-18 13:45:02 -0600 |
|---|---|---|
| committer | Ben Johnson <benbjohnson@yahoo.com> | 2015-05-18 13:45:02 -0600 |
| commit | df52bd0803e5062c92eb947ef63fdf0dd74c5753 (patch) | |
| tree | 3ad764d7a6580f264cd7ceea9175ef76a021775f /db.go | |
| parent | make ignoring Truncate() explicit (diff) | |
| download | dedo-df52bd0803e5062c92eb947ef63fdf0dd74c5753.tar.gz dedo-df52bd0803e5062c92eb947ef63fdf0dd74c5753.tar.xz | |
Add test case inline documentation.
Diffstat (limited to 'db.go')
| -rw-r--r-- | db.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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() |
