Skip to content

Egliss/Paralleler

Repository files navigation

Paralleler

NuGet version (Paralleler) .NET

Summary

Paralleler is additional implement of System.Threading.Parallel.
this library provide some usuful feature of the parallel system.

  • Parallel.ForAsync with ordered index
  • Parallel.ForEachAsync with ordered element
  • Awaitable Parallel

System.Threading.Tasks.Parallel

Parallel.For is running function with unordered index. for example,

using System.Threading.Tasks;
void Function()
{
    Parallel.For(0, 100, (int index) => Console.WriteLine(index));
}

the code will output next result.

60
54
55
...
0
30
24
61
62

If you can't accept this result, my library may be useful.

Usage

using System;
using Egliss.Paralleler;

async Task Function()
{
    await OrderedParallel.ForAsync(0, 100, (index) => Console.WriteLine(index), Environment.ProcessorCount / 2);
}

output

0
1
2
...
96
97
95 
98
99

index is not synchronized so, encounting 95 after 97. OrderedParallel.For() just tries to perform operations in ascending order as much as possible.

This library won't help if you need a tighter index sync.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published