Esempio n. 1
0
func (m *Queue) Destroy() {
	if m.closeCond != nil {
		return
	}

	m.closeCond = sync2.NewLockCond(nil)
	if len(m.queue) > 0 {
		m.closeCond.Wait()
	}
	close(m.queue)
}
Esempio n. 2
0
// Close stop receive new job, and waiting for all exists jobs to be processed
func (p *Pool) Close() {
	p.lock.Lock()
	if p.closeCond != nil {
		p.lock.Unlock()
		return
	}

	p.closeCond = sync2.NewLockCond(nil)
	if len(p.jobs) != 0 {
		p.lock.Unlock()
		p.closeCond.Wait()
	} else {
		p.lock.Unlock()
	}

	close(p.jobs)
}