yage.core.parallel
Authors:
Eric Poggel
License:
LGPL v3
- Parallel!(T)
parallel
(T)(T[] array);
- Allow a foreach loop to be executed concurrently accross multiple threads.
Care must be taken that no iteration affects data from any other.
Elements will most likely not be processed in order.
Break statements are not supported inside
parallel
foreach.
The advantage of
parallel
foreach breaks down when loop bodies are small and fast.
This is probably because less inlining occurs vs a regular foreach.
This has caused random crashes with an access violation and weird stack traces.
It's not known if
parallel
is at fault or the code inside the foreach body.
Example:
int[] array = [1, 2, 3, 4, 5];
foreach(i, elem; parallel(array))
array[i] = elem+1;
|