Open pzfreo opened 5 years ago
I agree this would be useful.
The first idea that comes to mind for this is to have a library function with a parameter of type map<future<T>>
, which would:
[string,T]
saying which future completed and what the completion wasThat seems a very elegant solution to the problem.
Description: Many consensus algorithms or business processes require starting n workers and waiting until some proportion (e.g. n/2+1) have completed. This is very difficult in Ballerina today because the only way seems to be to loop and sleep.
For example in the raft consensus algorithm, there are voting processes where a system sends out an election command in parallel to n servers and waits until more than half of the n servers have responded yes. n is variable and can change at runtime.
It seems the only way to do this today is to use "start" n times, and then loop through checking which are done and the responses. The result is either a tight loop or using runtime:sleep, neither of which seems ideal. It might be nice to have language support for this.
Suggested Labels: workers, concurrency, futures, wait
Code sample that shows issue: Not available
Related Issues: