Closed xiyler closed 5 months ago
A simple API for this feature is to follow create an Operator named Async
, which in practice just adds a new cTask to a ReactiveObject's cTasks field.
For example:
scope:Derived(function(self)
Async(self, function()
task.wait(2)
Write(self, 20)
end)
return 0
end)
While a simple API like this doesn't cover as much as other async-focused libraries (Promises, Futures, etc) do, it satisfices our main goal, which is running operations that are async safely.
Additionally, as much as performance is concerned, we could pool coroutines so the cost of creating coroutines is minimized.
On a side note, this requires Write
to be able to actually overwrite data of ReactiveObjects with a _computer
.
Added on master
It could be worthwhile to add first class support for high level management of async operations. It's important to note that Vinum technically allows for writing custom async primitives using RNode's cancelableTasks. These CTasks get "cancel()ed" before every state recomputation, so it's a reliable place for placing something like async stuff.
This feature is deferred to Vinum 0.5