github.com/akerouanton/docker@v1.11.0-rc3/libcontainerd/pausemonitor_linux.go (about)

     1  package libcontainerd
     2  
     3  // pauseMonitor is helper to get notifications from pause state changes.
     4  type pauseMonitor struct {
     5  	waiters map[string][]chan struct{}
     6  }
     7  
     8  func (m *pauseMonitor) handle(t string) {
     9  	if m.waiters == nil {
    10  		return
    11  	}
    12  	q, ok := m.waiters[t]
    13  	if !ok {
    14  		return
    15  	}
    16  	if len(q) > 0 {
    17  		close(q[0])
    18  		m.waiters[t] = q[1:]
    19  	}
    20  }
    21  
    22  func (m *pauseMonitor) append(t string, waiter chan struct{}) {
    23  	if m.waiters == nil {
    24  		m.waiters = make(map[string][]chan struct{})
    25  	}
    26  	_, ok := m.waiters[t]
    27  	if !ok {
    28  		m.waiters[t] = make([]chan struct{}, 0)
    29  	}
    30  	m.waiters[t] = append(m.waiters[t], waiter)
    31  }