Function ecs_readonly_begin

Synopsis

#include <include/flecs.h>

FLECS_API bool ecs_readonly_begin(ecs_world_t *world)

Description

Begin readonly mode. Readonly mode guarantees that no mutations will occur on the world, which makes the world safe to access from multiple threads. While the world is in readonly mode, operations are deferred.

Note that while similar to ecs_defer_begin, deferring only does not guarantee the world is not mutated. Operations that are not deferred (like creating a query) update data structures on the world and are allowed when deferring is enabled, but not when the world is in readonly mode.

A call to ecs_readonly_begin must be followed up with ecs_readonly_end.

The ecs_progress() function automatically enables readonly mode while systems are executed.

When a world has more than one stage, the specific stage must be provided to mutating ECS operations. Failing to do so will throw a readonly assert. A world typically has more than one stage when using threads. An example:

ecs_set_stage_count(world, 2); ecs_stage_t *stage = ecs_get_stage(world, 1);

ecs_readonly_begin(world); ecs_add(world, e, Tag); // readonly assert ecs_add(stage, e, Tag); // OK

Parameters

world - The world

Returns
Whether world is in readonly mode.

Source

Line 4207 in include/flecs.h.