Flecs.NET icon indicating copy to clipboard operation
Flecs.NET copied to clipboard

Multi-threaded queries

Open BeanCheeseBurrito opened this issue 11 months ago • 0 comments

Add multi-threaded versions of .Each/.Iter/.Run.

query.EachJob(static (Iter it, int i, ref Position p, ref Velocity v) =>
{
    p.X += v.X;
    p.Y += v.Y;
});

query.IterJob(static (Iter it, Span<Position> p, Span<Velocity> v) =>
{
    foreach (int i in it)
    {
        p[i].X += v[i].X;
        p[i].Y += v[i].Y;
    }
});

query.RunJob((Iter it) =>
{
    while (it.Next())
    {
        Span<Position> p = it.Span<Position>(0);
        Span<Velocity> v = it.Span<Velocity>(1);
        
        foreach (int i in it)
        {
            p[i].X += v[i].X;
            p[i].Y += v[i].Y;
        }
    }
});

BeanCheeseBurrito avatar Mar 14 '25 15:03 BeanCheeseBurrito