Version: 2023.1
LanguageEnglish
  • C#

AtomicSafetyHandle.CheckGetSecondaryDataPointerAndThrow

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void CheckGetSecondaryDataPointerAndThrow(Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle);

Parameters

handle The AtomicSafetyHandle to check.

Description

Check if the data pointer is in a valid state to be aliased by a view on the container which will use the secondary version number.

When implementing container methods which create memory-aliasing views, such as GetEnumerator or AsArray, use this method to check that it is safe to copy the pointer to the container's backing memory into the new view structure.

This is different to AtomicSafetyHandle.CheckReadAndThrow because that method will throw if there is a pending job which is writing to the container; this method will not throw if the job which is writing to the container is doing so through a handle which uses the secondary version. The difference is that in the latter case the job cannot affect the size of the container, and so there is no risk of it reallocating the container's backing memory and causing the data pointer copied to the view to become invalid.

For more information about container version numbers, see Copying NativeContainer structures.