Queue thread

Kai Meyer kai at unixlords.com
Mon Nov 21 09:45:45 PST 2011


On 11/20/2011 02:36 PM, bioinfornatics wrote:
> Le dimanche 20 novembre 2011 à 03:09 -0800, Jonathan M Davis a écrit :
>> On Sunday, November 20, 2011 11:59:14 bioinfornatics wrote:
>>> Dear,
>>> I would like to know if they are a way to run run a queue thread an run
>>> (nb core * 2 + 1) = nb thread in same time
>>>
>>> something like:
>>> size_t nb_core = 9;
>>> Queue q = new Queue( 9, process1, process2, process3 );
>>> q.run();
>>
>> Look at std.parallelism. I don't know if it'll do quite what you want, but
>> it's the closest that you'll find in Phobos.
>>
>> - Jonathan M Davis
>
>
> i have tred to use TaskPool but i fail
> Error: /parallelism.d(434): Error: no property 'opCall' for type
> 'fastcgi.application.Page'
>
> the problem raise here:
> https://github.com/bioinfornatics/DFastCGI/blob/master/src/fastcgi/application.d#L74 (i think)
>
> Any help are welcome
>
> thanks
>

I looked at your code, and saw this:
https://github.com/bioinfornatics/DFastCGI/blob/master/src/fastcgi/application.d#L18
_taskPool   = new TaskPool( totalCPUs * threadsPerCPU + 1);

On my machine, that would come out to 1:

[kai.meyer at kai-rhel6 D]$ cat cpu.d
import std.stdio;
import std.parallelism : totalCPUs, TaskPool, task;
import std.cpuid : threadsPerCPU;

void main()
{
     writefln("totalCPUs %s", totalCPUs);
     writefln("threadsPerCPU %s", threadsPerCPU);
     writefln("totalCPUs * threadsPerCPU + 1 = %s\n", totalCPUs * 
threadsPerCPU + 1);
}
[kai.meyer at kai-rhel6 D]$ dmd -run cpu.d
totalCPUs 8
threadsPerCPU 0
totalCPUs * threadsPerCPU + 1 = 1

Did you mean this?
_taskPool   = new TaskPool( totalCPUs * (threadsPerCPU + 1));


More information about the Digitalmars-d-learn mailing list