code: func (e *endpoint) Readiness(mask waiter.EventMask) waiter.EventMask {
  	result := waiter.EventMask(0)
  
  	e.mu.RLock()
  	defer e.mu.RUnlock()
  
  	switch e.state {
  	case stateInitial, stateBound, stateConnecting:
  		// Ready for nothing.
  
  	case stateClosed, stateError:
  		// Ready for anything.
  		result = mask
  
  	case stateListen:
  		// Check if there's anything in the accepted channel.
  		if (mask & waiter.EventIn) != 0 {
  			if len(e.acceptedChan) > 0 {
  				result |= waiter.EventIn
  			}
  		}
  
  	case stateConnected:
  		// Determine if the endpoint is writable if requested.
  		if (mask & waiter.EventOut) != 0 {
  			e.sndBufMu.Lock()
  			if e.sndClosed || e.sndBufUsed < e.sndBufSize {
  				result |= waiter.EventOut
  			}
  			e.sndBufMu.Unlock()
  		}
  
  		// Determine if the endpoint is readable if requested.
  		if (mask & waiter.EventIn) != 0 {
  			e.rcvListMu.Lock()
  			if e.rcvBufUsed > 0 || e.rcvClosed {
  				result |= waiter.EventIn
  			}
  			e.rcvListMu.Unlock()
  		}
  	}
  
  	return result
  }
docs: // Readiness returns the current readiness of the endpoint. For example, if
  // waiter.EventIn is set, the endpoint is immediately readable.