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

Method beforeScriptExecution

threadworker.go:42–83  ·  view source on GitHub ↗

beforeScriptExecution returns the name of the script or an empty string on shutdown

()

Source from the content-addressed store, hash-verified

40
41// beforeScriptExecution returns the name of the script or an empty string on shutdown
42func (handler *workerThread) beforeScriptExecution() string {
43 switch handler.state.Get() {
44 case state.TransitionRequested:
45 if handler.worker.onThreadShutdown != nil {
46 handler.worker.onThreadShutdown(handler.thread.threadIndex)
47 }
48 handler.worker.detachThread(handler.thread)
49 return handler.thread.transitionToNewHandler()
50 case state.Restarting:
51 if handler.worker.onThreadShutdown != nil {
52 handler.worker.onThreadShutdown(handler.thread.threadIndex)
53 }
54 handler.state.Set(state.Yielding)
55 handler.state.WaitFor(state.Ready, state.ShuttingDown)
56 return handler.beforeScriptExecution()
57 case state.Ready, state.TransitionComplete:
58 handler.thread.updateContext(true)
59 if handler.worker.onThreadReady != nil {
60 handler.worker.onThreadReady(handler.thread.threadIndex)
61 }
62
63 setupWorkerScript(handler, handler.worker)
64
65 return handler.worker.fileName
66 case state.Rebooting:
67 return ""
68 case state.RebootReady:
69 handler.requestCount = 0
70 handler.state.Set(state.Ready)
71 return handler.beforeScriptExecution()
72 case state.ShuttingDown:
73 if handler.worker.onThreadShutdown != nil {
74 handler.worker.onThreadShutdown(handler.thread.threadIndex)
75 }
76 handler.worker.detachThread(handler.thread)
77
78 // signal to stop
79 return ""
80 }
81
82 panic("unexpected state: " + handler.state.Name())
83}
84
85func (handler *workerThread) afterScriptExecution(exitStatus int) {
86 tearDownWorkerScript(handler, exitStatus)

Callers

nothing calls this directly

Calls 8

setupWorkerScriptFunction · 0.85
GetMethod · 0.80
detachThreadMethod · 0.80
SetMethod · 0.80
WaitForMethod · 0.80
updateContextMethod · 0.80
NameMethod · 0.80

Tested by

no test coverage detected