boot starts the underlying PHP thread
()
| 59 | |
| 60 | // boot starts the underlying PHP thread |
| 61 | func (thread *phpThread) boot() { |
| 62 | // thread must be in reserved state to boot |
| 63 | if !thread.state.CompareAndSwap(state.Reserved, state.Booting) && !thread.state.CompareAndSwap(state.BootRequested, state.Booting) { |
| 64 | panic("thread is not in reserved state: " + thread.state.Name()) |
| 65 | } |
| 66 | |
| 67 | // boot threads as inactive |
| 68 | thread.handlerMu.Lock() |
| 69 | thread.handler = &inactiveThread{thread: thread} |
| 70 | thread.drainChan = make(chan struct{}) |
| 71 | thread.handlerMu.Unlock() |
| 72 | |
| 73 | // start the actual posix thread - TODO: try this with go threads instead |
| 74 | if !C.frankenphp_new_php_thread(C.uintptr_t(thread.threadIndex)) { |
| 75 | panic("unable to create thread") |
| 76 | } |
| 77 | |
| 78 | thread.state.WaitFor(state.Inactive) |
| 79 | } |
| 80 | |
| 81 | // reboot exits the C thread loop for full ZTS cleanup, then spawns a fresh C thread. |
| 82 | // Returns false if the thread is no longer in Ready state (e.g. shutting down). |