Beef icon indicating copy to clipboard operation
Beef copied to clipboard

Added the Parallel class and the ForEach method in it

Open larkliy opened this issue 8 months ago • 3 comments

larkliy avatar Apr 09 '25 14:04 larkliy

I tested it, but had some issues. Probably related to the Task implementation. It works fine in debug, but not release builds. The following seems to have an infinite loop going:

        int[2] items = .(0, 1);
        Parallel.ForEach<int>(items, scope (item) => { });

Some other thoughts on the code:

  • If this goes into the corlib, it would be nice having it be available on non-Windows as well (Maybe use Platform.BfpSystem_GetNumLogicalCPUs()?)
  • tasks can use scope instead of new. task can use scope::

m910q avatar May 10 '25 11:05 m910q

I think it would be nice for someone to make a parallels library, but I'm not really thinking this is something that needs to go into corlib at the moment.

System.Threading.Tasks is uncooked and probably should be taken out of corlib as it stands, even...

bfiete avatar May 10 '25 13:05 bfiete

System.Threading.Tasks is uncooked and probably should be taken out of corlib as it stands, even...

Yeah, and to expand on that, I have also written a parallel class before, and IIRC the Task class has some thread race issues. For my project, I ended up just writing my own simple task class using WaitEvent.

disarray2077 avatar May 10 '25 14:05 disarray2077