Add RwMutexes to all collections. #116

This commit is contained in:
Andrey Smirnov
2014-10-08 16:16:07 +04:00
parent 2ed76f1e4c
commit ac983ff65d
4 changed files with 20 additions and 8 deletions
+4 -1
View File
@@ -7,6 +7,7 @@ import (
"github.com/smira/aptly/database"
"github.com/ugorji/go/codec"
"log"
"sync"
)
// LocalRepo is a collection of packages created locally
@@ -88,6 +89,7 @@ func (repo *LocalRepo) RefKey() []byte {
// LocalRepoCollection does listing, updating/adding/deleting of LocalRepos
type LocalRepoCollection struct {
*sync.RWMutex
db database.Storage
list []*LocalRepo
}
@@ -95,7 +97,8 @@ type LocalRepoCollection struct {
// NewLocalRepoCollection loads LocalRepos from DB and makes up collection
func NewLocalRepoCollection(db database.Storage) *LocalRepoCollection {
result := &LocalRepoCollection{
db: db,
RWMutex: &sync.RWMutex{},
db: db,
}
blobs := db.FetchByPrefix([]byte("L"))