Various improvements

This commit is contained in:
2015-06-10 14:43:57 +03:00
parent 3ab95e13fe
commit 52548b09e1
20 changed files with 45 additions and 55 deletions

View File

@ -66,5 +66,26 @@ namespace TransportGame.Utils
if (Success.HasValue && !Success.Value)
throw new Exception("Task failed", thrownException);
}
public static IEnumerable InParallel(params IEnumerable[] funcs)
{
// Obtain iterators
var iterators = funcs.Select(enumerable => enumerable.GetEnumerator()).ToArray();
// Execute a slice of each
bool stop;
do
{
stop = true;
foreach (var it in iterators)
if (it.MoveNext())
{
yield return it.Current;
stop = false;
}
} while (!stop);
}
}
}