[Proposal] Concurrent Block
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
[(Ported from Roslyn Repo)](https://github.com/dotnet/roslyn/issues/14604)
# Concurrent Block
I'm thinking this along the lines of abstracting away the underlying machinery, so that the programmer can express that this section can be run concurrently. This proposal is for introduction of a new block construct in the C# and VB language, which permits code with the block to be run concurrently.
``` C#
T0 a;
T1 b;
concurrent
{
a = await PartA();
b = await PartB();
}
```
``` vb
Dim a As T0
Dim b As T1
concurrent
a = await PartA()
b = await PartB()
end concurrent
```
There will be some form of flow analysis to check the "lines" can be run concurrently. eg there have no interdependencies with each other. The result will be the same as if it was run consecutively.
**Join Patterns**
Express the join pattern.
``` c#
winner = concurrent { a , b } when any;
results = concurrent { a , b } when all;
```
**target**
Have the ability to specify where the concurrent code should be executed, eg GPUCPU.
``` c#
winner = concurrent gpu { a , b } when any;
results = concurrent gpu { a , b } when all;
```
---
The `ConcurrentBlock` is a indicating a pattern. How that pattern is implemented is handled by another component, let's call it a `PatternMaker`. The **PatternMaker** takes the code in the block _translates_ it into form that can be processed by the `Concurrency Target`, which is similar to how `async` blocks work.
``` c#
concurrent Task {} /* Transforms uses Task (possible Default) */
concurrent Thread {} /* Transform uses Threads */
concurrent Process { } /* Transform uses Processes */
concurrent Fibres {} /* Transform uses Fibres */
concurrent GPU { } /* Transform use GPU concurrency */
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.