Skip to content

Instantly share code, notes, and snippets.

@nandordudas
Created October 26, 2024 07:56
Show Gist options
  • Save nandordudas/19cb6f30abaf86a347988164a0e3e898 to your computer and use it in GitHub Desktop.
Save nandordudas/19cb6f30abaf86a347988164a0e3e898 to your computer and use it in GitHub Desktop.
flowchart TB
    subgraph MainThread["Main Thread"]
        direction TB
        Store["Pinia Store"]
        Orchestrator["Worker Orchestrator"]
        Monitor["Health Monitor"]
        Metrics["Performance Metrics"]
        
        Orchestrator --> Store
        Orchestrator --> Monitor
        Orchestrator --> Metrics
    end
    
    subgraph SharedMemory["Shared Memory (32KB)"]
        direction LR
        GameState["Game State\n(0-1023 bytes)"]
        InputState["Input State\n(1024-1279 bytes)"]
    end

    subgraph Workers["Web Workers"]
        direction TB
        Game["Game Worker"]
        Render["Render Worker"]
        Network["Network Worker"]
    end

    subgraph Channels["Message Channels"]
        GameRender["Game ⟺ Render"]
        GameNetwork["Game ⟺ Network"]
        RenderNetwork["Render ⟺ Network"]
    end

    %% Main connections
    Orchestrator --> Game
    Orchestrator --> Render
    Orchestrator --> Network
    
    %% Shared memory access
    Game --> SharedMemory
    Render --> SharedMemory
    Network --> SharedMemory
    
    %% Channel connections
    Game <--> GameRender
    Game <--> GameNetwork
    Render <--> GameRender
    Render <--> RenderNetwork
    Network <--> GameNetwork
    Network <--> RenderNetwork
    
    %% Health monitoring
    Monitor --> Game
    Monitor --> Render
    Monitor --> Network
    
    %% Performance metrics
    Game --> Metrics
    Render --> Metrics
    Network --> Metrics
    
    %% Styling
    classDef thread fill:#e1f5fe,stroke:#01579b
    classDef worker fill:#fff3e0,stroke:#ff6f00
    classDef channel fill:#f3e5f5,stroke:#4a148c
    classDef memory fill:#e8f5e9,stroke:#1b5e20
    classDef monitor fill:#fbe9e7,stroke:#bf360c
    
    class MainThread thread
    class Game,Render,Network worker
    class GameRender,GameNetwork,RenderNetwork channel
    class SharedMemory,GameState,InputState memory
    class Monitor,Metrics monitor

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