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