www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - parallel foreach hangs

reply "Daniel Kozak" <kozzi11 gmail.com> writes:
this code never end

import std.stdio;
import std.file;
import std.parallelism : parallel;
import std.algorithm : filter;

void main(string[] args)
{
     foreach(d; parallel(args[1 .. $], 1))
     {
         auto phpFiles = 
filter!`endsWith(a.name,".php")`(dirEntries(d,SpanMode.depth));
         writeln(phpFiles);
     }
}
Sep 22 2014
next sibling parent "anonymous" <anonymous example.com> writes:
On Monday, 22 September 2014 at 11:25:53 UTC, Daniel Kozak wrote:
 this code never end

 import std.stdio;
 import std.file;
 import std.parallelism : parallel;
 import std.algorithm : filter;

 void main(string[] args)
 {
     foreach(d; parallel(args[1 .. $], 1))
     {
         auto phpFiles = 
 filter!`endsWith(a.name,".php")`(dirEntries(d,SpanMode.depth));
         writeln(phpFiles);
     }
 }
Works for me. Be aware that dirEntries traverses the whole directory structure recursively. So when you let it loose on something like root or your home directory, it may take a while. If that's not it, try to define a complete test scenario: directories, files, compiler version, command line for compiling, command line for running, etc.
Sep 22 2014
prev sibling parent "kiran kumari" <kiranfabzen gmail.com> writes:
On Monday, 22 September 2014 at 11:25:53 UTC, Daniel Kozak wrote:
 this code never end

 import std.stdio;
 import std.file;
 import std.parallelism : parallel;
 import std.algorithm : filter;

 void main(string[] args)
 {
     foreach(d; parallel(args[1 .. $], 1))
     {
         auto phpFiles = 
 filter!`endsWith(a.name,".php")`(dirEntries(d,SpanMode.depth));
         writeln(phpFiles);
     }
 }
see more example http://techgurulab.com/course/java-quiz-online/
Sep 24 2014