decline-cookies / anvil-unity-dots

Unity DOTS and ECS specific additions and extensions to Anvil
MIT License
4 stars 1 forks source link

Access wrapper duplicate type #273

Closed mbaker3 closed 1 year ago

mbaker3 commented 1 year ago

Add the ability to require multiple data stream writers of the same type on a task driver job. The API proposed here provides a solution until a proper solution can be devised during #224

This solution takes advantage of the fact that all data stream pending collections share the same access handle this means that, from a job dependency perspective, getting write access to a stream instance also provides write access to all other stream instances of the same type (shared/wide writing).

What is the current behaviour?

Developers are unable to include writers to multiple data streams of the same type in their job. This most commonly comes up when there are cancel requests to multiple task drivers that a job may want to make during execution.

What is the new behaviour?

Developers can now include multiple data streams of the same type in their job.

How it works

On the first write request we create an access wrapper as we normally would. For all other write requests after the first one we keep the same access wrapper and track the specific instance request for safety checks. (only if ANVIL_DEBUG_SAFETY is enabled)

During fulfill we use the provided stream instance to generate a writer and make a safety check to ensure that instance was required during job config.

Edge Case Behaviour (WhenANVIL_DEBUG_SAFETY is enabled)

What issues does this resolve?

Resolve: #245

What PRs does this depend on?

Does this introduce a breaking change?

mbaker3 commented 1 year ago

All comments addressed. Ready for re-review