setState sets and broadcasts the provided state if it is greater than the current state and the error if one has not already been set.
(state State, err error)
| 216 | // setState sets and broadcasts the provided state if it is greater than the |
| 217 | // current state and the error if one has not already been set. |
| 218 | func (s *ptyState) setState(state State, err error) { |
| 219 | s.cond.L.Lock() |
| 220 | defer s.cond.L.Unlock() |
| 221 | // Cannot regress states. For example, trying to close after the process is |
| 222 | // done should leave us in the done state and not the closing state. |
| 223 | if state <= s.state { |
| 224 | return |
| 225 | } |
| 226 | s.error = err |
| 227 | s.state = state |
| 228 | s.cond.Broadcast() |
| 229 | } |
| 230 | |
| 231 | // waitForState blocks until the state or a greater one is reached. |
| 232 | func (s *ptyState) waitForState(state State) (State, error) { |
no test coverage detected