[WIP] refactor network queue#3093
Draft
mercury233 wants to merge 7 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors duel/replay/single message handling so that engine/network threads no longer process messages directly; instead they signal the main thread to analyze messages and drive UI updates, reducing the amount of manual locking around UI/state mutations.
Changes:
- Added a main-thread “analyze” dispatch path (
analyzeSignal/analyzeDone,ProcessAnalyzeQueue) and frame/render helpers (RenderOneFrame,WaitForAction, updatedWaitFrameSignal). - Updated single play, replay, and LAN client packet handling to marshal message analysis onto the main thread and replaced several blocking
Signal.Reset()+Wait()patterns withWaitForAction(). - Removed a number of
gMutexlock/unlock pairs around UI interactions that are now intended to happen on the main thread.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gframe/single_mode.cpp | Marshals single-mode engine messages to main thread; replaces action waits with WaitForAction() (contains a parsing regression to fix). |
| gframe/replay_mode.cpp | Marshals replay message analysis to main thread and adjusts locking in replay restart/skip flows. |
| gframe/menu_handler.cpp | Removes gMutex guarding around menu/UI message boxes (main-thread event path). |
| gframe/game.h | Adds analyze types/signals, new frame/analyze helpers, and main-thread tracking/timer fields. |
| gframe/game.cpp | Implements main-thread analyze dispatch and refactors the render loop into RenderOneFrame(). |
| gframe/duelclient.cpp | Marshals STOC_GAME_MSG analysis to the main thread; replaces several UI waits with WaitForAction(). |
| gframe/drawing.cpp | Removes the old WaitFrameSignal() implementation (moved/expanded in game.cpp). |
| gframe/deck_con.cpp | Removes gMutex guarding around deck builder UI popups (main-thread event path). |
| gframe/client_field.cpp | Removes gMutex around select-option popup (now expected on main thread). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
259
to
+267
| case STOC_GAME_MSG: { | ||
| if (len < 1 + sizeof(unsigned char)) | ||
| return; | ||
| ClientAnalyze(pdata, len - 1); | ||
| mainGame->analyzeMsg.type = ANALYZE_CLIENT; | ||
| mainGame->analyzeMsg.data = pdata; | ||
| mainGame->analyzeMsg.len = len - 1; | ||
| mainGame->analyzeDone.Reset(); | ||
| mainGame->analyzeSignal.Set(); | ||
| mainGame->analyzeDone.Wait(); |
Collaborator
Author
|
require #3104 to work properly |
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
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.
Changed event handling from direct processing on the network thread to enqueueing events for processing by the main thread, eliminating a large amount of manual locking.