38 lines
811 B
C#
38 lines
811 B
C#
using System;
|
|
using CeresSharp.Native;
|
|
using CeresSharp.Native.SafeHandles;
|
|
|
|
namespace CeresSharp.Advanced;
|
|
|
|
/// <summary>
|
|
/// Context for performance optimization.
|
|
/// Allows reuse of expensive objects across multiple solves.
|
|
/// </summary>
|
|
public sealed class Context : IDisposable
|
|
{
|
|
private readonly ContextHandle _handle;
|
|
private bool _disposed;
|
|
|
|
/// <summary>
|
|
/// Creates a new Context instance.
|
|
/// </summary>
|
|
public Context()
|
|
{
|
|
_handle = ContextHandle.Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the native handle.
|
|
/// </summary>
|
|
internal ContextHandle Handle => _handle;
|
|
|
|
public void Dispose()
|
|
{
|
|
if (!_disposed)
|
|
{
|
|
_handle?.Dispose();
|
|
_disposed = true;
|
|
}
|
|
}
|
|
}
|