Refactor Hydration module to use per-class volatile declarations #154
Labels
No labels
Blocked
Duplicate
MoSCoW/Could Have
MoSCoW/Must Have
MoSCoW/Should Have
Points/1
Points/13
Points/2
Points/21
Points/3
Points/5
Points/8
Priority/Backlog
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
State/Completed
State/In progress
State/In review
State/Paused
State/Unverified
State/Verified
State/Wont Do
Type/Bug
Type/Epic
Type/Feature
Type/Legendary
Type/Task
Type/Testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#153 Epic: Hydration System Refactor
aethyr/Aethyr
Reference: aethyr/Aethyr#154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Metadata
refactor(persistence): replace @@volatile with per-class @_volatile_vars in Hydrationfeature/m1-hydration-refactorBackground and Context
The
Hydrationmodule inlib/aethyr/core/util/hydration.rbuses@@volatile— a class variable shared across the entire inheritance hierarchy. WhenPublisherdeclaresvolatile :@local_registrationsandPlayerdeclaresvolatile :@help_library, :@player, both declarations write to the same@@volatilearray, causing declarations to leak across unrelated classes.The specification prescribes
@_volatile_vars(a class-level instance variable), ancestor chain traversal viacollect_volatile_vars, and aSERIALIZATION_MUTEXfor thread-safe dehydrate/rehydrate.Current Behavior
@@volatileis shared across all classes.Publisher.volatile_varsreturns all volatiles declared by any class in the hierarchy.Expected Behavior
Each class holds only its own
@_volatile_vars. At dehydrate time,collect_volatile_varswalks ancestors and unions their sets.SERIALIZATION_MUTEXprevents concurrent serialization corruption.Acceptance Criteria
Hydration::Volatileuses@_volatile_vars(class-level instance variable), not@@volatileown_volatile_varsreturns only the declaring class's volatilescollect_volatile_varswalksself.class.ancestorsand unions all@_volatile_varsHydration::SERIALIZATION_MUTEXexists and guards dehydrate/rehydratePublisher.own_volatile_varsreturnsSet[:@local_registrations]onlyPlayer.own_volatile_varsreturnsSet[:@help_library, :@player]onlySubtasks
Hydration::Volatilemodule: replace@@volatilewith@_volatile_vars(Set)own_volatile_varsclass method returning only the declaring class's setcollect_volatile_varsinstance method walkingself.class.ancestorsHydration::SERIALIZATION_MUTEX = Mutex.newdehydrateto acquire mutex, callcollect_volatile_vars, strip volatile ivarsrehydrateto acquire mutex, restore or initialize volatile ivarsPlayer#dehydrateandPlayer#rehydrateoverrides for new APIPublishervolatile declarations don't leak to non-Publisher classesbundle exec rake unit, fix any failuresdocs/developer/architecture.mdpersistence sectiontests/integration/verifying game objects serialize and deserialize correctly with refactored hydration.bundle exec rake unit_profileand verify no performance regressions.bundle exec rake unit. If coverage is <97% then review the current unit test coverage report atbuild/tests/unit/coverage/and use it to write new Cucumber based unit tests to improve code coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerunbundle exec rake unitto verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.bundle exec rake(default task: unit tests with coverage) andbundle exec rake integration, fix any errors if needed ensuring both pass across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.Definition of Done
This issue is complete when:
master, reviewed, and merged before this issue is marked done.