func (b *RefCountBox) Alloc() (DB, error) {
	b.Lock()
	defer b.Unlock()

	if b.db.DB == nil {
		if b.DataPath == nil {
			return DB{}, errorsp.WithStacks(ErrBoxDataPathNotSpecified)
		}
		var db DB
		var err error
		if b.OpenFunc == nil {
			db, err = Open(b.DataPath(), 0644, nil)
		} else {
			db, err = b.OpenFunc(b.DataPath())
		}
		if err != nil {
			return DB{}, errorsp.WithStacks(err)
		}
		b.db, b.count = db, 0
	}
	b.count++
	return b.db, nil
}
func (b *RefCountBox) Alloc() (DB, error) {
	b.Lock()
	defer b.Unlock()

	if b.db.DB == nil {
		if b.DataPath == nil {
			return DB{}, errorsp.WithStacks(ErrBoxDataPathNotSpecified)
		}
		var db DB
		var err error
		if b.OpenFunc == nil {
			db, err = Open(b.DataPath(), 0644, nil)
		} else {
			db, err = b.OpenFunc(b.DataPath())
		}
		if err != nil {
			return DB{}, errorsp.WithStacks(err)
		}
		b.db, b.count = db, 0
	}
	b.count++
	return b.db, nil
}
func ( b * RefCountBox ) Alloc ( ) ( DB , error ) { b . Lock ( ) defer b . Unlock ( ) if b . db . DB == nil { if b . DataPath == nil { return DB { } , errorsp . WithStacks ( ErrBoxDataPathNotSpecified ) } var db DB var err error if b . OpenFunc == nil { db , err = Open ( b . DataPath ( ) , 0644 , nil ) } else { db , err = b . OpenFunc ( b . DataPath ( ) ) } if err != nil { return DB { } , errorsp . WithStacks ( err ) } b . db , b . count = db , 0 } b . count ++ return b . db , nil }
// Alloc opens a DB if not openned yet. It adds a reference if already openned.
Alloc opens a DB if not openned yet . It adds a reference if already openned .