-
Notifications
You must be signed in to change notification settings - Fork 399
extgen: (types) make go arrays more consistent with PHP arrays #1800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ba8e305
Makes go arrays more consistent with PHP arrays.
AlliBalliBaba af7a4f4
NewAssociativeArray.
AlliBalliBaba 009ad61
linting
AlliBalliBaba 4cb9337
go linting
AlliBalliBaba 274d2ff
Exposes all primitive types.
AlliBalliBaba 08ed97c
Removes pointer alias
AlliBalliBaba 0fff364
linting
AlliBalliBaba d720e2f
Optimizes hash update.
AlliBalliBaba d79c770
Fixes extgen tests.
AlliBalliBaba e1c0dc2
Moves file to tests.
AlliBalliBaba 2288f49
Fixes suggested by @dunglas.
AlliBalliBaba d4c264d
Replaces 'interface{}' with 'any'.
AlliBalliBaba 89f5a06
Panics on wrong zval.
AlliBalliBaba 5ac0f17
interface improvements as suggested by @dunglas.
AlliBalliBaba dc3fe3b
Adjusts docs.
AlliBalliBaba a43e226
Adjusts docs.
AlliBalliBaba 7c297c6
Removes PackedArray alias and adjusts docs.
AlliBalliBaba 86f563f
Updates docs.
AlliBalliBaba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package frankenphp | ||
|
|
||
| import ( | ||
| "sync" | ||
| ) | ||
|
|
||
| // representation of a thread that handles tasks directly assigned by go | ||
| // implements the threadHandler interface | ||
| type taskThread struct { | ||
| thread *phpThread | ||
| execChan chan *task | ||
| } | ||
|
|
||
| // task callbacks will be executed directly on the PHP thread | ||
| // therefore having full access to the PHP runtime | ||
| type task struct { | ||
| callback func() | ||
| done sync.Mutex | ||
| } | ||
|
|
||
| func newTask(cb func()) *task { | ||
| t := &task{callback: cb} | ||
| t.done.Lock() | ||
|
|
||
| return t | ||
| } | ||
|
|
||
| func (t *task) waitForCompletion() { | ||
| t.done.Lock() | ||
| } | ||
|
|
||
| func convertToTaskThread(thread *phpThread) *taskThread { | ||
| handler := &taskThread{ | ||
| thread: thread, | ||
| execChan: make(chan *task), | ||
| } | ||
| thread.setHandler(handler) | ||
| return handler | ||
| } | ||
|
|
||
| func (handler *taskThread) beforeScriptExecution() string { | ||
| thread := handler.thread | ||
|
|
||
| switch thread.state.get() { | ||
| case stateTransitionRequested: | ||
| return thread.transitionToNewHandler() | ||
| case stateBooting, stateTransitionComplete: | ||
| thread.state.set(stateReady) | ||
| handler.waitForTasks() | ||
|
|
||
| return handler.beforeScriptExecution() | ||
| case stateReady: | ||
| handler.waitForTasks() | ||
|
|
||
| return handler.beforeScriptExecution() | ||
| case stateShuttingDown: | ||
| // signal to stop | ||
| return "" | ||
| } | ||
| panic("unexpected state: " + thread.state.name()) | ||
| } | ||
|
|
||
| func (handler *taskThread) afterScriptExecution(int) { | ||
| panic("task threads should not execute scripts") | ||
| } | ||
|
|
||
| func (handler *taskThread) getRequestContext() *frankenPHPContext { | ||
| return nil | ||
| } | ||
|
|
||
| func (handler *taskThread) name() string { | ||
| return "Task PHP Thread" | ||
| } | ||
|
|
||
| func (handler *taskThread) waitForTasks() { | ||
| for { | ||
| select { | ||
| case task := <-handler.execChan: | ||
| task.callback() | ||
| task.done.Unlock() // unlock the task to signal completion | ||
| case <-handler.thread.drainChan: | ||
| // thread is shutting down, do not execute the function | ||
| return | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func (handler *taskThread) execute(t *task) { | ||
| handler.execChan <- t | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.