Added XML documentation comments to the `JobScheduler` class and its methods. Added a new method `GetJobStatus` in the `JobScheduler` class for job status retrieval. Added a new `CollectionHandle` struct for collection management. Added a new test class `TestUnsafeSparseSet` with unit tests for `UnsafeSparseSet`. Changed the `WorkerThread` class to improve job retrieval logic with a new `FindJob` method. Changed the `DynamicArena` class by removing commented-out code to streamline memory management. Removed commented-out code in the `WorkerThread` class for improved readability. Removed the `ArenaAllocator` struct from `AllocationManager` to clean up unused code. Removed the `ParallelWriter` struct from `UnsafeSparseSet`, indicating a shift in handling sparse sets.
47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
namespace Misaki.HighPerformance.LowLevel.Collections;
|
|
|
|
public readonly struct CollectionHandle
|
|
{
|
|
public readonly int id;
|
|
public readonly int generation;
|
|
|
|
public static CollectionHandle Invalid => new(-1, -1);
|
|
|
|
public bool IsValid => this != Invalid;
|
|
|
|
internal CollectionHandle(int id, int generation)
|
|
{
|
|
this.id = id;
|
|
this.generation = generation;
|
|
}
|
|
|
|
public bool Equals(CollectionHandle other)
|
|
{
|
|
return id == other.id && generation == other.generation;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is CollectionHandle handle && Equals(handle);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(id, generation);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return IsValid ? $"CollectionHandle({id}, {generation})" : "CollectionHandle(Invalid)";
|
|
}
|
|
|
|
public static bool operator ==(CollectionHandle left, CollectionHandle right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public static bool operator !=(CollectionHandle left, CollectionHandle right)
|
|
{
|
|
return !(left == right);
|
|
}
|
|
} |