Skip to content
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

Add priority to SHFlow, replace _flowPool with flat_set #1079

Merged
merged 20 commits into from
Nov 13, 2024

Conversation

sinkingsugar
Copy link
Member

No description provided.

Check for duplicate wire scheduling in `_flowPool.insert`. If insertion fails due to an existing entry, log an error and throw an `SHException` with a descriptive message, ensuring wires are only scheduled once.
Introduce `setWirePriority` function and `priority` field to `SHWire` for controlling scheduling priority in the runtime. Update flow creation to pass priority and clamp the value within integer bounds. Modify `network.shs` tests to assign priorities, ensuring priority-based execution consistency across test cases.
This commit removes all `Priority` tags from various network test shards, including `network-test-server`, `client-init`, and `network-test-client` configurations. Adjustments ensure cleaner scheduling without explicit priority settings, enhancing maintainability and alignment with current shard practices.
Refactor network-ws.shs to use a new @wire and @schedule approach for running tests with Network.WS client and server. Replace Network.Client and Network.Server with WebSocket-based versions in main-test wire.
Copy link

codecov bot commented Nov 10, 2024

Codecov Report

Attention: Patch coverage is 90.76923% with 12 lines in your changes missing coverage. Please review.

Project coverage is 79.60%. Comparing base (5eff824) to head (bcd20d5).
Report is 21 commits behind head on devel.

Files with missing lines Patch % Lines
shards/core/runtime.hpp 89.09% 6 Missing ⚠️
shards/modules/core/wires.cpp 81.81% 4 Missing ⚠️
shards/modules/core/core.hpp 66.66% 1 Missing ⚠️
shards/modules/core/wires.hpp 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #1079      +/-   ##
==========================================
- Coverage   79.61%   79.60%   -0.02%     
==========================================
  Files         358      358              
  Lines       61505    61438      -67     
==========================================
- Hits        48968    48908      -60     
+ Misses      12537    12530       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Refactor `SHFlow` structure initialization by adding a constructor with `priority`, `wire`, and `paused` arguments, and implement a less-than operator to handle priority-based sorting in `_flowPool`. Remove redundant `SHFlowLess` struct, streamline flow pool removal with improved iterator handling, and add trace logging for wire cleanup in `SHMesh`. Enhance serialization by adding `priority` to wire read/write operations and fix formatting in audio and genetic modules.
…ow swapping in mesh, and ensure resumption logic consistency

This commit introduces improvements to `SHFlow` by encapsulating the paused state and wire pointer, allowing for getter and setter methods (`isPaused`, `setPaused`, `getWire`). Flow swapping logic is centralized in a new `swapFlows` function within `SHMesh`, ensuring consistent handling of flow priority and proper resumption behavior in cases where a resumer is set. This update also adjusts `SuspendWire` and `ResumeWire` to use the encapsulated paused state, and refactors logic in `wireCleanedUp` to manage flow removal accurately. Finally, `SwitchTo` updates `context->flow` using the mesh swap for better flow state management across ticks and wire transitions.
Refactor SHWire's event handling by centralizing dispatcher triggering within each wire instance instead of relying on the mesh. Add scoped connections for OnStart and OnCleanup events, enhancing safety and automatic disconnection upon destruction. Replace `scheduled` checks with direct removal from `_flowPool` during cleanup. Simplify `tick` function flow by updating iterator handling, removing unused flow state assertions, and eliminating redundant `wireCleanedUp` function from SHMesh. Refactor `Spawn` and `WhenDone` to handle cleanup connections using `scoped_connection` for safer lifecycle management.
Remove unnecessary `_connectedMesh` member and related checks in Spawn and WhenDone. Establish scoped connections for each `ManyWire` instance to handle cleanup events, reducing redundancy and ensuring that each wire has its own scoped connection.
Refactor `SHWire` to handle nested wire delegation with `childWire`, allowing `SwitchTo` operations to seamlessly transition control between wires. Add `tickingWire()` function to retrieve the active wire context, updating calls to `tick()` accordingly. Ensure proper child wire cleanup by resetting `childWire` and `resumer` pointers post-switch. Add validation and scheduling for non-started wires and enhance error logging for wire failures. Adjust logging and unscheduling logic to reflect expected `SwitchTo` behavior.
shards/tests/network-ws.shs Outdated Show resolved Hide resolved
- Update `SHWire` to use `uniqueId` for consistent ordering in `SHMesh`
- Add `regenerateId` to ensure wires are added at the end of the mesh list
- Modify `tickingWire` function to traverse nested `childWire` correctly
- Add assertions in `WireDoppelgangerPool` for wire integrity checks
- Include `allCleared` function in `SHMesh` to verify all containers are empty
- Log wire creation and ensure ID regeneration
@sinkingsugar sinkingsugar merged commit 1f96b0a into devel Nov 13, 2024
11 checks passed
@sinkingsugar sinkingsugar deleted the gio/flat-set-flowpool branch November 13, 2024 04:11
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