Am 07.12.2017 um 07:38 schrieb kerdemdemir:

I am running many tasks parallel like:

vibe.core.concurrency.Future!(bool)[] futureList;
foreach ( currency ; currencyList)
	futureList ~= vibe.core.concurrency.async(&DoSomething, pointerParamater);

int counter = 0;
while(futureList.any!(a => !a.ready())) //--> Blocking until all of them ready
	if ( counter > 14 )
		return false;

return true;

I am having a simple time out and bailing on the function after a timeout.
The problem is I afraid the task which weren't ready are still running in the background and modifying pointer parameter which causes a race condition.

I think my simple solution is before exiting this function running through not ready task and stopping them. This is of course if stop functionality exists. Does it exists? Do you guys know a better solution ?


I was under the impression that Future would already join the internal
task at the end of the scope, but apparently that has not been
implemented so far. Unfortunately the Task object is not accessible,
so the only way to make sure that all futures have finished is to
explicitly call getResult() for each one before leaving the scope.

There is also Task.interrupt(), which generates an
InterruptException in the destination task to make it stop
prematurely. That could be used to implement a Future.cancel() method.
Is this what you'd need, or would just waiting for the results be