WaitFor blocks until the thread reaches a certain state
(states ...State)
| 152 | |
| 153 | // WaitFor blocks until the thread reaches a certain state |
| 154 | func (ts *ThreadState) WaitFor(states ...State) { |
| 155 | ts.mu.Lock() |
| 156 | if slices.Contains(states, ts.currentState) { |
| 157 | ts.mu.Unlock() |
| 158 | |
| 159 | return |
| 160 | } |
| 161 | |
| 162 | sub := stateSubscriber{ |
| 163 | states: states, |
| 164 | ch: make(chan struct{}), |
| 165 | } |
| 166 | ts.subscribers = append(ts.subscribers, sub) |
| 167 | ts.mu.Unlock() |
| 168 | <-sub.ch |
| 169 | } |
| 170 | |
| 171 | // RequestSafeStateChange safely requests a state change from a different goroutine |
| 172 | func (ts *ThreadState) RequestSafeStateChange(nextState State) bool { |
no outgoing calls