fix bug lock is released too soon

refactor_docs
Helin Wang 8 years ago
parent 4808e22e04
commit bc33f9b165

@ -110,7 +110,7 @@ func (s *Service) SendGrads(grads []Gradient, dummy *int) error {
} }
s.mu.Lock() s.mu.Lock()
s.mu.Unlock() defer s.mu.Unlock()
for _, g := range grads { for _, g := range grads {
if _, ok := s.paramMap[g.Name]; !ok { if _, ok := s.paramMap[g.Name]; !ok {
@ -134,7 +134,7 @@ func (s *Service) SendGrads(grads []Gradient, dummy *int) error {
func (s *Service) GetParams(names []string, parameters *[]Parameter) error { func (s *Service) GetParams(names []string, parameters *[]Parameter) error {
<-s.initialized <-s.initialized
s.mu.Lock() s.mu.Lock()
s.mu.Unlock() defer s.mu.Unlock()
for _, n := range names { for _, n := range names {
if _, ok := s.paramMap[n]; !ok { if _, ok := s.paramMap[n]; !ok {

Loading…
Cancel
Save