MCPcopy Index your code
hub / github.com/php/frankenphp / RequestSafeStateChange

Method RequestSafeStateChange

internal/state/state.go:172–194  ·  view source on GitHub ↗

RequestSafeStateChange safely requests a state change from a different goroutine

(nextState State)

Source from the content-addressed store, hash-verified

170
171// RequestSafeStateChange safely requests a state change from a different goroutine
172func (ts *ThreadState) RequestSafeStateChange(nextState State) bool {
173 ts.mu.Lock()
174 switch ts.currentState {
175 // disallow state changes if shutting down or done
176 case ShuttingDown, Done, Reserved:
177 ts.mu.Unlock()
178
179 return false
180 // ready and inactive are safe states to transition from
181 case Ready, Inactive:
182 ts.currentState = nextState
183 ts.notifySubscribers(nextState)
184 ts.mu.Unlock()
185
186 return true
187 }
188 ts.mu.Unlock()
189
190 // wait for the state to change to a safe state
191 ts.WaitFor(Ready, Inactive, ShuttingDown)
192
193 return ts.RequestSafeStateChange(nextState)
194}
195
196// MarkAsWaiting hints that the thread reached a stable state and is waiting for requests or shutdown
197func (ts *ThreadState) MarkAsWaiting(isWaiting bool) {

Callers 3

shutdownMethod · 0.80
setHandlerMethod · 0.80
drainWorkerThreadsFunction · 0.80

Calls 2

notifySubscribersMethod · 0.95
WaitForMethod · 0.95

Tested by

no test coverage detected