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 flag to control asset versioning when getting write access #727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roby2014
Copy link
Member

Description

Added a flag to Assets::write in order to control whether the version of assets should be incremented when getting write access.

Checklist

  • Self-review changes.
  • Evaluate impact on the documentation.
  • Write new samples.

@github-actions
Copy link
Contributor

PR Preview Action v1.4.4
🚀 Deployed preview to https://GameDevTecnico.github.io/cubos/pr-preview/pr-727/
on branch gh-pages at 2023-10-17 01:26 UTC

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (174a787) 38.15% compared to head (69ead5e) 38.15%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #727   +/-   ##
=======================================
  Coverage   38.15%   38.15%           
=======================================
  Files          99       99           
  Lines        6576     6576           
=======================================
  Hits         2509     2509           
  Misses       4067     4067           

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

@roby2014 roby2014 changed the title feat(engine): add flag to control asset versioning when getting write access Add flag to control asset versioning when getting write access Oct 17, 2023
@RiscadoA
Copy link
Member

This PR should also add a method used to bump the version manually, but I'm not sure how we would do this. Maybe we should add a third locking function, instead of adding an argument to the existing one.

E.g.:

auto assetWrite = assets->potentialWrite(asset);
/* ... potentially do changes, just like before */
if (modified)
{
    // consumes the assetWrite lock, unlocking the asset, but before that, increments the asset's version.
    assets->confirmWrite(std::move(assetWrite));
}

The thing is, currently AssetWrite is just an alias for core::memory::WriteGuard<T, std::unique_lock<std::shared_mutex>>, and for this to work, it would also need to store the UUID of the asset being accessed. Otherwise, we would need to add an asset handle argument to the confirmWrite method, which is duplicating information and thus error prone.

Maybe instead of making it an alias, we could make it a child class of the WriteGuard and then just store the extra UUID field, which could then be used in the confirmWrite implementation.

Copy link
Member

@RiscadoA RiscadoA left a comment

Choose a reason for hiding this comment

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

Forgot to request changes!

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

Successfully merging this pull request may close these issues.

Allow accessing assets with write access without incrementing their version
2 participants