mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Fix race condition error
This commit is contained in:
		@@ -41,8 +41,8 @@ func (s *jobsQueue) Dequeue(n int) []*jobItem {
 | 
				
			|||||||
	s.lock.Lock()
 | 
						s.lock.Lock()
 | 
				
			||||||
	defer s.lock.Unlock()
 | 
						defer s.lock.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if n > s.Size() {
 | 
						if n > s.size() {
 | 
				
			||||||
		n = s.Size()
 | 
							n = s.size()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	items := s.items[0:n]
 | 
						items := s.items[0:n]
 | 
				
			||||||
@@ -52,6 +52,13 @@ func (s *jobsQueue) Dequeue(n int) []*jobItem {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *jobsQueue) Size() int {
 | 
					func (s *jobsQueue) Size() int {
 | 
				
			||||||
 | 
						s.lock.Lock()
 | 
				
			||||||
 | 
						defer s.lock.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return s.size()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s *jobsQueue) size() int {
 | 
				
			||||||
	return len(s.items)
 | 
						return len(s.items)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user