github.com/Cloud-Foundations/Dominator@v0.3.4/lib/goroutine/impl.go (about)

     1  package goroutine
     2  
     3  func newGoroutine() *Goroutine {
     4  	channel := make(chan Function)
     5  	go managerLoop(channel)
     6  	return &Goroutine{channel}
     7  }
     8  
     9  func managerLoop(start <-chan Function) {
    10  	for {
    11  		fn, ok := <-start
    12  		if !ok {
    13  			return
    14  		}
    15  		if fn != nil {
    16  			fn()
    17  		}
    18  	}
    19  }