//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Implementation of a JobSystem using a thread pool
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:25
///
/// class JobSystemThreadPool final : public JobSystemWithBarrier
///
///
///
///
/// Implementation of a JobSystem using a thread pool
///
/// Note that this is considered an example implementation. It is expected that when you integrate
/// the physics engine into your own project that you'll provide your own implementation of the
/// JobSystem built on top of whatever job system your project uses.
///
///
[InteropHandle]
public readonly partial struct JobSystemThreadPool : IDisposable
{
///
///
/// Creates a thread pool.
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:32
///
/// JobSystemThreadPool(uint inMaxJobs, uint inMaxBarriers, int inNumThreads = -1)
///
///
///
///
/// Creates a thread pool.
/// @see JobSystemThreadPool::Init
///
///
public static JobSystemThreadPool Create(uint maxJobs, uint maxBarriers, int numThreads = -1) =>
Jolt.PInvoke.JobSystemThreadPool_Create(maxJobs, maxBarriers, numThreads);
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:33
///
/// JobSystemThreadPool() = default
///
///
public static JobSystemThreadPool Create() => Jolt.PInvoke.JobSystemThreadPool_Create_2();
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:38
///
/// void SetThreadInitFunction(const InitExitFunction &inInitFunction)
///
///
///
///
/// initFunction: The callback is invoked from native code: it must be a static method marked
/// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])], and userData is passed back to it verbatim.
/// Pass null for none. The callback and userData are retained by the native object until they are replaced
/// or the owner is destroyed - keep whatever userData points at (a GCHandle, an allocation) alive for at
/// least that long, and don't free it at the end of the call.
///
///
public unsafe void SetThreadInitFunction(
delegate* unmanaged[Cdecl] initFunction,
nint initFunctionUserData
) => Jolt.PInvoke.JobSystemThreadPool_SetThreadInitFunction(this, initFunction, initFunctionUserData);
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:39
///
/// void SetThreadExitFunction(const InitExitFunction &inExitFunction)
///
///
///
///
/// exitFunction: The callback is invoked from native code: it must be a static method marked
/// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])], and userData is passed back to it verbatim.
/// Pass null for none. The callback and userData are retained by the native object until they are replaced
/// or the owner is destroyed - keep whatever userData points at (a GCHandle, an allocation) alive for at
/// least that long, and don't free it at the end of the call.
///
///
public unsafe void SetThreadExitFunction(
delegate* unmanaged[Cdecl] exitFunction,
nint exitFunctionUserData
) => Jolt.PInvoke.JobSystemThreadPool_SetThreadExitFunction(this, exitFunction, exitFunctionUserData);
///
///
/// Initialize the thread pool
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:45
///
/// void Init(uint inMaxJobs, uint inMaxBarriers, int inNumThreads = -1)
///
///
///
///
/// Initialize the thread pool
/// @param inMaxJobs Max number of jobs that can be allocated at any time
/// @param inMaxBarriers Max number of barriers that can be allocated at any time
/// @param inNumThreads Number of threads to start (the number of concurrent jobs is 1 more because the main thread will also run jobs while waiting for a barrier to complete). Use -1 to auto detect the amount of CPU's.
///
///
public void Init(uint maxJobs, uint maxBarriers, int numThreads = -1) =>
Jolt.PInvoke.JobSystemThreadPool_Init(this, maxJobs, maxBarriers, numThreads);
///
public int GetMaxConcurrency() => ((JobSystem)this).GetMaxConcurrency();
///
///
/// Change the max concurrency after initialization
///
///
/// C++:
/// Jolt/Core/JobSystemThreadPool.h:52
///
/// void SetNumThreads(int inNumThreads)
///
///
public void SetNumThreads(int numThreads) => Jolt.PInvoke.JobSystemThreadPool_SetNumThreads(this, numThreads);
public static implicit operator JobSystemWithBarrier(JobSystemThreadPool value) =>
Unsafe.BitCast(value);
public static implicit operator JobSystem(JobSystemThreadPool value) =>
Unsafe.BitCast(value);
public void Dispose() => Jolt.PInvoke.JobSystemThreadPool_Destroy(this);
///
public void Init(uint maxBarriers) => ((JobSystemWithBarrier)this).Init(maxBarriers);
}
}