flecs-hub / flecs-lua

Lua script host for flecs
MIT License
51 stars 9 forks source link

How are lua systems forced to run on the main thread? #11

Closed sro5h closed 2 years ago

sro5h commented 2 years ago

I saw that in system.c there is an assert to make sure that lua systems are run on the main thread:

ecs_assert(stage_id == 0, ECS_INTERNAL_ERROR, "Lua callbacks must run on the main thread");

But i can't find any code that actually disables multithreading while initializing lua systems or for the world as a whole. Am i missing something?

randy408 commented 2 years ago

For v3 there is a new ecs_system_desc_t.multi_threaded, it's initialized to 0 (i.e. false) by default, that's why you don't see any specific code for that.

That assert is from the v2 days where you either disabled threading or scheduled the systems on your own, there was no per-system scheduling option.