-
Notifications
You must be signed in to change notification settings - Fork 0
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
Rewrite the main loop for simplicity and perf #108
Merged
Merged
Conversation
This file contains 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
We now relentlessly enqueue buffer appends to the main thread. It's certainly not as efficient as batching all the writes in some interval, but in practice it shouldn't be a problem. In particular, we no longer for a write to complete before beginning the next read, and we also don't wait for data on the wire before continuing with data we have buffered.
Still need to make sure the GameConnection processes everything correctly, and possibly rename it to GameTransport
Fixes issue where you could not delete a connection buffer after the remote side disconnected
We still hang when attempting to send something, however.... Not quite sure why yet
There is now only one way to get onto the main thread!
Should keep CPU usage more consistently low due to more consistent sleep. We basically use the Dispatcher to send a no-op fn to the main thread as a signal that the UiEvents can be polled. We can probably simplify further and possibly process more than a single dispatched event per loop (as we had been doing).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a massive refactor that consolidates all the many ways we have of getting onto the main thread into a single Dispatcher abstraction. In particular:
ApiManagerDelegate
since we no longer need it; this solves the discussion around re-entrant scripting since we don't have to remove anything fromapp::State
to respond to scripting methods.May just be placebo, but things do feel a bit snappier now!
Future work might:
Option
onapp::State
; not strictly necessary (or very relevant to this PR) but also I don't think we need it, and that refactor would certainly simplify access to connections