github.com/searKing/golang/go@v1.2.117/x/dispatch/waitgroup.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package dispatch
     6  
     7  type WaitGroup interface {
     8  	Add(delta int)
     9  	Done()
    10  	Wait()
    11  }
    12  
    13  var nullWG = &emptyWG{}
    14  
    15  type emptyWG struct {
    16  	WaitGroup
    17  }
    18  
    19  func (wg *emptyWG) Add(delta int) {
    20  	return
    21  }
    22  
    23  // Done decrements the waitGroup counter by one.
    24  func (wg *emptyWG) Done() {
    25  	return
    26  }
    27  
    28  // Wait blocks until the waitGroup counter is zero.
    29  func (wg *emptyWG) Wait() {
    30  	return
    31  }