vinum-team / Vinum

A modern reactive state management library for correctness and speed.
MIT License
16 stars 1 forks source link

Add `NoYield` helper to disable thread usage for yield-safe operations #18

Closed sinlerdev closed 1 year ago

sinlerdev commented 1 year ago

Objects like Observes reuse threads to spawn their connections, as their idea is to bridge between Vinum, and the "real" world- and of course, this includes yielding code.

However, it is starting to feel that making all of our observes yield-safe is quite useless (or even annoying!) in some cases- the most notable one is real-time binding between Vinum, and any layer that you want to reconcile your state into- as usually, you would need the binding operation to be instant- and usage of coroutines may introduce a bit reliability issue with operations latency.

A "counter" point to this point, is that the layer at which we reconcile our state must not be used by us- in fact, it is just a reflection point. And while this can be true in some cases (or the impact of the said issue is minimal), it falls apart when we introduce observes to architectures like ECS, where the reflection point is the ECS' world, and its components, and they all need to be instantly updated.

The solution I have in mind is to introduce a NoYield helper (modifier, whatever) that will make the observe not be able to use threads at all. While the NoYield is intended to be a general tool, its usage is currently limited to Observes only.