MCPcopy
hub / github.com/dropbox/godropbox / performTransition

Function performTransition

sys/filelock/filelock_test.go:240–271  ·  view source on GitHub ↗
(errChan chan error, bgState, testState, action string)

Source from the content-addressed store, hash-verified

238}
239
240func performTransition(errChan chan error, bgState, testState, action string) {
241 lockName := bgState + testState + action
242 bgLock := New(lockName)
243 tLock := New(lockName)
244
245 if bgState == "LOCKED" {
246 bgLock.Lock()
247 } else if bgState == "RLOCKED" {
248 bgLock.RLock()
249 }
250
251 if testState == "LOCKED" {
252 tLock.Lock()
253 } else if testState == "RLOCKED" {
254 tLock.RLock()
255 }
256
257 switch action {
258 case "TryRLock":
259 errChan <- tLock.TryRLock()
260 case "RLock":
261 errChan <- tLock.RLock()
262 case "TryLock":
263 errChan <- tLock.TryLock()
264 case "Lock":
265 errChan <- tLock.Lock()
266 case "RUnlock":
267 errChan <- tLock.RUnlock()
268 case "Unlock":
269 errChan <- tLock.Unlock()
270 }
271}

Callers 1

TestAllTransitionsMethod · 0.85

Calls 7

NewFunction · 0.70
LockMethod · 0.65
RLockMethod · 0.65
TryRLockMethod · 0.65
TryLockMethod · 0.65
RUnlockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected