Merge pull request #3795 from greatroar/sema

backend: Move semaphores to a dedicated package
This commit is contained in:
MichaelEischer
2022-06-18 17:12:01 +02:00
committed by GitHub
11 changed files with 101 additions and 98 deletions

View File

@@ -11,6 +11,7 @@ import (
"sync"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/backend/sema"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
@@ -32,12 +33,12 @@ const connectionCount = 2
type MemoryBackend struct {
data memMap
m sync.Mutex
sem *backend.Semaphore
sem sema.Semaphore
}
// New returns a new backend that saves all data in a map in memory.
func New() *MemoryBackend {
sem, err := backend.NewSemaphore(connectionCount)
sem, err := sema.New(connectionCount)
if err != nil {
panic(err)
}