github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/multiplexing/channel.go (about)

     1  package multiplexing
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // isClosed checks if a signaling channel is closed.
     8  func isClosed(channel <-chan struct{}) bool {
     9  	select {
    10  	case <-channel:
    11  		return true
    12  	default:
    13  		return false
    14  	}
    15  }
    16  
    17  // wasPopulatedWithTime checks if a time signaling channel was populated with a
    18  // time value and drains it if so.
    19  func wasPopulatedWithTime(channel <-chan time.Time) bool {
    20  	select {
    21  	case <-channel:
    22  		return true
    23  	default:
    24  		return false
    25  	}
    26  }