Skip to content

[WIP] refactor network queue#3093

Draft
mercury233 wants to merge 7 commits into
Fluorohydride:masterfrom
mercury233:patch-network-queue
Draft

[WIP] refactor network queue#3093
mercury233 wants to merge 7 commits into
Fluorohydride:masterfrom
mercury233:patch-network-queue

Conversation

@mercury233

Copy link
Copy Markdown
Collaborator

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, updated WaitFrameSignal).
  • 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 with WaitForAction().
  • Removed a number of gMutex lock/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 thread gframe/single_mode.cpp
Comment thread gframe/duelclient.cpp
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();
@mercury233

Copy link
Copy Markdown
Collaborator Author

require #3104 to work properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants