Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove ThreadSafeDatastore #120

Merged
merged 1 commit into from
Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion basic_ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 0 additions & 8 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions mount/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 2 additions & 5 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -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()
Expand Down