|
13 | 13 | // guaranteed to be the same on each platform. For example, some UNIX-like
|
14 | 14 | // operating systems will transparently convert a shared lock to an exclusive
|
15 | 15 | // lock. If you Unlock() the flock from a location where you believe that you
|
16 |
| -// have the shared lock, you may accidently drop the exclusive lock. |
| 16 | +// have the shared lock, you may accidentally drop the exclusive lock. |
17 | 17 | package flock
|
18 | 18 |
|
19 | 19 | import (
|
@@ -86,17 +86,17 @@ func (f *Flock) String() string {
|
86 | 86 | // conditions is met: TryLock succeeds, TryLock fails with error, or Context
|
87 | 87 | // Done channel is closed.
|
88 | 88 | func (f *Flock) TryLockContext(ctx context.Context, retryDelay time.Duration) (bool, error) {
|
89 |
| - return tryCtx(f.TryLock, ctx, retryDelay) |
| 89 | + return tryCtx(ctx, f.TryLock, retryDelay) |
90 | 90 | }
|
91 | 91 |
|
92 | 92 | // TryRLockContext repeatedly tries to take a shared lock until one of the
|
93 | 93 | // conditions is met: TryRLock succeeds, TryRLock fails with error, or Context
|
94 | 94 | // Done channel is closed.
|
95 | 95 | func (f *Flock) TryRLockContext(ctx context.Context, retryDelay time.Duration) (bool, error) {
|
96 |
| - return tryCtx(f.TryRLock, ctx, retryDelay) |
| 96 | + return tryCtx(ctx, f.TryRLock, retryDelay) |
97 | 97 | }
|
98 | 98 |
|
99 |
| -func tryCtx(fn func() (bool, error), ctx context.Context, retryDelay time.Duration) (bool, error) { |
| 99 | +func tryCtx(ctx context.Context, fn func() (bool, error), retryDelay time.Duration) (bool, error) { |
100 | 100 | if ctx.Err() != nil {
|
101 | 101 | return false, ctx.Err()
|
102 | 102 | }
|
|
0 commit comments