diff --git a/basic_ds.go b/basic_ds.go index 5c5a0ad..ccfe14d 100644 --- a/basic_ds.go +++ b/basic_ds.go @@ -13,7 +13,9 @@ type MapDatastore struct { values map[Key][]byte } -// NewMapDatastore constructs a MapDatastore +// NewMapDatastore constructs a MapDatastore. It is _not_ thread-safe by +// default, wrap using sync.MutexWrap if you need thread safety (the answer here +// is usually yes). func NewMapDatastore() (d *MapDatastore) { return &MapDatastore{ values: make(map[Key][]byte), diff --git a/datastore.go b/datastore.go index b9ced85..eec1932 100644 --- a/datastore.go +++ b/datastore.go @@ -102,14 +102,6 @@ type Batching interface { // actually support batching. var ErrBatchUnsupported = errors.New("this datastore does not support batching") -// ThreadSafeDatastore is an interface that all threadsafe datastore should -// implement to leverage type safety checks. -type ThreadSafeDatastore interface { - Datastore - - IsThreadSafe() -} - // CheckedDatastore is an interface that should be implemented by datastores // which may need checking on-disk data integrity. type CheckedDatastore interface { diff --git a/mount/mount.go b/mount/mount.go index 9e2622f..9d26f46 100644 --- a/mount/mount.go +++ b/mount/mount.go @@ -190,8 +190,6 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) { }), nil } -func (d *Datastore) IsThreadSafe() {} - func (d *Datastore) Close() error { for _, d := range d.mounts { err := d.Datastore.Close() diff --git a/sync/sync.go b/sync/sync.go index d222016..c9ec73a 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -15,8 +15,8 @@ type MutexDatastore struct { child ds.Datastore } -// MutexWrap constructs a datastore with a coarse lock around -// the entire datastore, for every single operation +// MutexWrap constructs a datastore with a coarse lock around the entire +// datastore, for every single operation. func MutexWrap(d ds.Datastore) *MutexDatastore { return &MutexDatastore{child: d} } @@ -26,9 +26,6 @@ func (d *MutexDatastore) Children() []ds.Datastore { return []ds.Datastore{d.child} } -// IsThreadSafe implements ThreadSafeDatastore -func (d *MutexDatastore) IsThreadSafe() {} - // Put implements Datastore.Put func (d *MutexDatastore) Put(key ds.Key, value []byte) (err error) { d.Lock()