func (m *Manager) Subscribe(ctx context.Context) *ManagerSubscription {
	m.mutex.Lock()
	defer m.mutex.Unlock()

	ret := newSubscription()

	m.subscriptions = append(m.subscriptions, ret)

	go func() {
		<-ctx.Done()
		m.mutex.Lock()
		defer m.mutex.Unlock()

		ret.close()

		// remove from the list
		for i, s := range m.subscriptions {
			if s == ret {
				m.subscriptions = append(m.subscriptions[:i], m.subscriptions[i+1:]...)
				break
			}
		}
	}()

	return ret
}
// Subscribe subscribes to changes to jobs in the manager queue.
Subscribe subscribes to changes to jobs in the manager queue.
// Subscribe subscribes to changes to jobs in the manager queue .
func (m *Manager) Subscribe(ctx context.Context) *ManagerSubscription {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	ret := newSubscription()
	m.subscriptions = append(m.subscriptions, ret)
	go func() {
		<-ctx.Done()
		m.mutex.Lock()
		defer m.mutex.Unlock()
		ret.close()
		for i, s := range m.subscriptions {
			if s == ret {
				m.subscriptions = append(m.subscriptions[:i], m.subscriptions[i+1:]...)
				break
			}
		}
	}()
	return ret
}
func ( m * Manager ) Subscribe ( ctx context . Context ) * ManagerSubscription { m . mutex . Lock ( ) defer m . mutex . Unlock ( ) ret := newSubscription ( ) m . subscriptions = append ( m . subscriptions , ret ) go func ( ) { <- ctx . Done ( ) m . mutex . Lock ( ) defer m . mutex . Unlock ( ) ret . close ( ) for i , s := range m . subscriptions { if s == ret { m . subscriptions = append ( m . subscriptions [ : i ] , m . subscriptions [ i + 1 : ] ... ) break } } } ( ) return ret }
Subscribe subscribes to changes to jobs in the manager queue.
Subscribe subscribes to changes to jobs in the manager queue .
// remove from the list