| | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | using Unity.Burst; |
| | 6 | | using Unity.Collections; |
| | 7 | | using Unity.Jobs; |
| | 8 | |
|
| | 9 | | namespace GDX.Jobs.ParallelFor |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Fills a <see cref="Unity.Collections.NativeArray{T}" /> typed as <see cref="System.Int32" /> with a value in |
| | 13 | | /// parallel. |
| | 14 | | /// </summary> |
| | 15 | | [BurstCompile] |
| | 16 | | public struct IntegerBufferFillJob : IJobParallelFor |
| | 17 | | { |
| | 18 | | /// <summary> |
| | 19 | | /// <para>The <see cref="Unity.Collections.NativeArray{T}" /> which is going to be filled.</para> |
| | 20 | | /// </summary> |
| | 21 | | /// <remarks>Write-only.</remarks> |
| | 22 | | [WriteOnly] public NativeArray<int> Buffer; |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// <para>The <see cref="System.Int32" /> value to fill the native array with.</para> |
| | 26 | | /// </summary> |
| | 27 | | /// <remarks>Read-only.</remarks> |
| | 28 | | [ReadOnly] public int FillValue; |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Executable work for the provided index. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="index">The index of the Parallel for loop at which to perform work.</param> |
| | 34 | | public void Execute(int index) |
| 0 | 35 | | { |
| 0 | 36 | | Buffer[index] = FillValue; |
| 0 | 37 | | } |
| | 38 | | } |
| | 39 | | } |