WithRLock executes a function while holding a shared lock.
(ctx context.Context, fn func() error)
| 133 | |
| 134 | // WithRLock executes a function while holding a shared lock. |
| 135 | func (rl *RepositoryLock) WithRLock(ctx context.Context, fn func() error) error { |
| 136 | if err := rl.RLock(ctx); err != nil { |
| 137 | return err |
| 138 | } |
| 139 | defer rl.Unlock() |
| 140 | |
| 141 | return fn() |
| 142 | } |
| 143 | |
| 144 | // hashString creates a simple hash of a string for use in filenames |
| 145 | func hashString(s string) uint32 { |