Version: 2023.2

AtomicSafetyHandle.CheckGetSecondaryDataPointerAndThrow

切换到手册
public static void CheckGetSecondaryDataPointerAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle);

参数

handle The AtomicSafetyHandle to check.

描述

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.