Files
frankenphp/php_thread.go
Alexander Stecher d99b16a158 perf: remove all cgo handles (#1073)
* 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>
2024-10-09 07:31:09 +02:00

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
}