CheckGetSecondaryDataPointerAndThrow(AtomicSafetyHandle)
Check whether it's safe to create a memory-aliasing view to a native container.
Read time 1 minuteLast updated 19 days ago
Definition
- Type: Method
- Namespace: Unity.Collections.LowLevel.Unsafe
- Assembly: UnityEngine.CoreModule
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]public static void CheckGetSecondaryDataPointerAndThrow(AtomicSafetyHandle handle)
Parameters
The AtomicSafetyHandle to check.
Remarks
Use this method when you implement native container methods that create memory-aliasing views, such as or . This method checks whether it is safe to copy the data pointer to the backing memory of the native container into a new view structure that uses the secondary version number.
GetEnumeratorAsArrayThis method checks if there are pending jobs that might affect the size of the native container and risk reallocating the container's backing memory. This method doesn't throw an exception if the job writes through an that uses a secondary version number.
AtomicSafetyHandleThe difference between this method and is that that throws an exception if there are any pending jobs writing to the native container. throws an exception only if there is a risk of a job reallocating the native container's backing memory, which makes the data pointer copied to the view invalid.
<see cref="Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrow"></see>CheckReadAndThrowCheckGetSecondaryDataPointerAndThrowFor more information about secondary version numbers and safe access to dynamic containers, refer to Copying NativeContainer structures.
Additional Resources: NativeContainerAttribute.