Skip to content

ISystemDeclare

Martin Evans edited this page Aug 13, 2024 · 2 revisions

Systems which want to participate in safe multithreading must implement ISystemDeclare:

public interface ISystemDeclare<in TData>
    : ISystem<TData>
{
    void Declare(ref SystemDeclaration declaration);
}

In Declare the system must declare which components it reads and writes, this information is used to schedule the systems for parallel execution. Two systems are considered safe to execute in parallel if they do not read or write a component which the other is writing.

  • Parallel: Read<A>, Write<B>
  • Parallel: Read<A>, Read<B>
  • Parallel: Read<A>, Read<A>
  • NOT Parallel: Read<A>, Write<A>
  • NOT Parallel: Write<A>, Write<A>

DeclareSystemGroup

This is a system group which runs all child systems serially, but implements ISystemDeclare. This can be added to other parallel system groups as a system.

PhasedParallelSystemGroup

This is a system group which finds groups of systems that are safe to execute in parallel, and does so. The order of the systems is undefined and is not stable from frame to frame.

OrderedParallelSystemGroup

This is a system group which executes systems in parallel, in order. Each system waits for earlier systems which it conflicts with. Assuming your system declarations are correct this is identical to a serial system group executing in order.

Clone this wiki locally