Skip to content

Commit

Permalink
use mutex instead of rwmutex
Browse files Browse the repository at this point in the history
  • Loading branch information
monnand committed Jun 30, 2014
1 parent 3083a33 commit f99a50b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/registry/mock_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type MockPodRegistry struct {
err error
pod *api.Pod
pods []api.Pod
sync.RWMutex
sync.Mutex
}

func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
Expand All @@ -37,8 +37,8 @@ func MakeMockPodRegistry(pods []api.Pod) *MockPodRegistry {
}

func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod, error) {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
if registry.err != nil {
return registry.pods, registry.err
}
Expand All @@ -52,24 +52,24 @@ func (registry *MockPodRegistry) ListPods(selector labels.Selector) ([]api.Pod,
}

func (registry *MockPodRegistry) GetPod(podId string) (*api.Pod, error) {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.pod, registry.err
}

func (registry *MockPodRegistry) CreatePod(machine string, pod api.Pod) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}

func (registry *MockPodRegistry) UpdatePod(pod api.Pod) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}
func (registry *MockPodRegistry) DeletePod(podId string) error {
registry.RLock()
defer registry.RUnlock()
registry.Lock()
defer registry.Unlock()
return registry.err
}

0 comments on commit f99a50b

Please sign in to comment.