beforeScriptExecution returns the name of the script or an empty string on shutdown
()
| 40 | |
| 41 | // beforeScriptExecution returns the name of the script or an empty string on shutdown |
| 42 | func (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 | |
| 85 | func (handler *workerThread) afterScriptExecution(exitStatus int) { |
| 86 | tearDownWorkerScript(handler, exitStatus) |
nothing calls this directly
no test coverage detected