www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16601] New: No way to configure number of worker threads for

https://issues.dlang.org/show_bug.cgi?id=16601

          Issue ID: 16601
           Summary: No way to configure number of worker threads for
                    default taskPool
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

The parallel() and other global functions use the taskPool() getter method to
get the TaskPool on which to run parallel() on.

In case of scripts it's useful to be able to define the number of threads a
script can run in. But, the script then has to instantiate its own TaskPool and
remember to use it. It would be useful to be able to do something like:

-----
void main ( string[] args )
{
    size_t threads;
    getopt(
        args,
        "threads|t",
        "Max number of threads to run the script in",
        &threads);

    .taskPool.setThreadCount(threads);

    // runs in $threads number of threads
    foreach (item; buffer.parallel())
    {
    }
}
-----

--
Oct 07 2016