mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
* Removes Cgo handles and adds phpThreads. * Changes variable name. * Changes variable name. * Fixes merge error. * Removes unnecessary 'workers are done' check. * Removes panic. * Replaces int with uint32_t. * Changes index type to uintptr_t. * simplify --------- Co-authored-by: a.stecher <a.stecher@sportradar.com> Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
34 lines
574 B
Go
34 lines
574 B
Go
package frankenphp
|
|
|
|
// #include <stdint.h>
|
|
import "C"
|
|
import (
|
|
"net/http"
|
|
"runtime"
|
|
)
|
|
|
|
var phpThreads []*phpThread
|
|
|
|
type phpThread struct {
|
|
runtime.Pinner
|
|
|
|
mainRequest *http.Request
|
|
workerRequest *http.Request
|
|
worker *worker
|
|
}
|
|
|
|
func initPHPThreads(numThreads int) {
|
|
phpThreads = make([]*phpThread, 0, numThreads)
|
|
for i := 0; i < numThreads; i++ {
|
|
phpThreads = append(phpThreads, &phpThread{})
|
|
}
|
|
}
|
|
|
|
func (thread phpThread) getActiveRequest() *http.Request {
|
|
if thread.workerRequest != nil {
|
|
return thread.workerRequest
|
|
}
|
|
|
|
return thread.mainRequest
|
|
}
|