mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
157 lines
7.5 KiB
C#
157 lines
7.5 KiB
C#
// <auto-generated/>
|
|
// 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
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Implementation of a JobSystem using a thread pool
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L25">Jolt/Core/JobSystemThreadPool.h:25</see>
|
|
/// <br/>
|
|
/// <c>class JobSystemThreadPool final : public JobSystemWithBarrier</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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.
|
|
/// </code>
|
|
/// </remarks>
|
|
[InteropHandle]
|
|
public readonly partial struct JobSystemThreadPool : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// <para>
|
|
/// Creates a thread pool.
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L32">Jolt/Core/JobSystemThreadPool.h:32</see>
|
|
/// <br/>
|
|
/// <c>JobSystemThreadPool(uint inMaxJobs, uint inMaxBarriers, int inNumThreads = -1)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// Creates a thread pool.
|
|
/// @see JobSystemThreadPool::Init
|
|
/// </code>
|
|
/// </remarks>
|
|
public static JobSystemThreadPool Create(uint maxJobs, uint maxBarriers, int numThreads = -1) =>
|
|
Jolt.PInvoke.JobSystemThreadPool_Create(maxJobs, maxBarriers, numThreads);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L33">Jolt/Core/JobSystemThreadPool.h:33</see>
|
|
/// <br/>
|
|
/// <c>JobSystemThreadPool() = default</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public static JobSystemThreadPool Create() => Jolt.PInvoke.JobSystemThreadPool_Create_2();
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L38">Jolt/Core/JobSystemThreadPool.h:38</see>
|
|
/// <br/>
|
|
/// <c>void SetThreadInitFunction(const InitExitFunction &inInitFunction)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void SetThreadInitFunction(
|
|
delegate* unmanaged[Cdecl]<int, nint, void> initFunction,
|
|
nint initFunctionUserData
|
|
) => Jolt.PInvoke.JobSystemThreadPool_SetThreadInitFunction(this, initFunction, initFunctionUserData);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L39">Jolt/Core/JobSystemThreadPool.h:39</see>
|
|
/// <br/>
|
|
/// <c>void SetThreadExitFunction(const InitExitFunction &inExitFunction)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
public unsafe void SetThreadExitFunction(
|
|
delegate* unmanaged[Cdecl]<int, nint, void> exitFunction,
|
|
nint exitFunctionUserData
|
|
) => Jolt.PInvoke.JobSystemThreadPool_SetThreadExitFunction(this, exitFunction, exitFunctionUserData);
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Initialize the thread pool
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L45">Jolt/Core/JobSystemThreadPool.h:45</see>
|
|
/// <br/>
|
|
/// <c>void Init(uint inMaxJobs, uint inMaxBarriers, int inNumThreads = -1)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <code>
|
|
/// 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.
|
|
/// </code>
|
|
/// </remarks>
|
|
public void Init(uint maxJobs, uint maxBarriers, int numThreads = -1) =>
|
|
Jolt.PInvoke.JobSystemThreadPool_Init(this, maxJobs, maxBarriers, numThreads);
|
|
|
|
/// <inheritdoc cref="JobSystem.GetMaxConcurrency()"/>
|
|
public int GetMaxConcurrency() => ((JobSystem)this).GetMaxConcurrency();
|
|
|
|
/// <summary>
|
|
/// <para>
|
|
/// Change the max concurrency after initialization
|
|
/// </para>
|
|
/// <para>
|
|
/// C++:
|
|
/// <see href="https://github.com/jrouwe/JoltPhysics/blob/e77f175595e64cb44218cc9d9d56fc365ad0e36a/Jolt/Core/JobSystemThreadPool.h#L52">Jolt/Core/JobSystemThreadPool.h:52</see>
|
|
/// <br/>
|
|
/// <c>void SetNumThreads(int inNumThreads)</c>
|
|
/// </para>
|
|
/// </summary>
|
|
public void SetNumThreads(int numThreads) => Jolt.PInvoke.JobSystemThreadPool_SetNumThreads(this, numThreads);
|
|
|
|
public static implicit operator JobSystemWithBarrier(JobSystemThreadPool value) =>
|
|
Unsafe.BitCast<JobSystemThreadPool, JobSystemWithBarrier>(value);
|
|
|
|
public static implicit operator JobSystem(JobSystemThreadPool value) =>
|
|
Unsafe.BitCast<JobSystemThreadPool, JobSystem>(value);
|
|
|
|
public void Dispose() => Jolt.PInvoke.JobSystemThreadPool_Destroy(this);
|
|
|
|
/// <inheritdoc cref="JobSystemWithBarrier.Init(uint)"/>
|
|
public void Init(uint maxBarriers) => ((JobSystemWithBarrier)this).Init(maxBarriers);
|
|
}
|
|
}
|