Skip to content

Commit 84bdfce

Browse files
committed
Remove the store, Get, SetMax function
1 parent 3a5aae3 commit 84bdfce

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

lock/lock.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,6 @@ func New(id string, client LockClient) (lock *Lock) {
2525
return &Lock{id, client}
2626
}
2727

28-
func (l *Lock) store(f func(*Semaphore) error) (err error) {
29-
sem, err := l.client.Get()
30-
if err != nil {
31-
return err
32-
}
33-
34-
if err := f(sem); err != nil {
35-
return err
36-
}
37-
38-
err = l.client.Set(sem)
39-
if err != nil {
40-
return err
41-
}
42-
43-
return nil
44-
}
45-
46-
// Get returns the current semaphore value
47-
// if the underlying client returns an error, Get passes it through
48-
func (l *Lock) Get() (sem *Semaphore, err error) {
49-
sem, err = l.client.Get()
50-
if err != nil {
51-
return nil, err
52-
}
53-
54-
return sem, nil
55-
}
56-
57-
// SetMax sets the maximum number of holders the semaphore will allow
58-
// it returns the current semaphore and the previous maximum
59-
// if there is a problem getting or setting the semaphore, this function will
60-
// pass on errors from the underlying client
61-
func (l *Lock) SetMax(max int) (sem *Semaphore, oldMax int, err error) {
62-
var (
63-
semRet *Semaphore
64-
old int
65-
)
66-
67-
return semRet, old, l.store(func(sem *Semaphore) error {
68-
old = sem.Max
69-
semRet = sem
70-
return sem.SetMax(max)
71-
})
72-
}
73-
7428
// Lock adds this lock id as a holder to the semaphore
7529
// it will return an error if there is a problem getting or setting the
7630
// semaphore, or if the maximum number of holders has been reached, or if a lock

0 commit comments

Comments
 (0)