moved locking down south

This commit is contained in:
Radu Ioan Fericean
2014-01-09 22:31:08 +02:00
parent 0278f08de4
commit 127e7650fa

View File

@@ -40,11 +40,10 @@ func NewScheduler() *Scheduler {
func (s *Scheduler) Loop() {
for {
s.Lock()
for len(s.queue) == 0 { //hang here if empty
s.Unlock()
<-s.restartLoop
}
s.Lock()
a0 := s.queue[0]
now := time.Now()
if a0.GetNextStartTime().Equal(now) || a0.GetNextStartTime().Before(now) {