On Friday, 18 August 2017 at 11:24:24 UTC, Moritz Maxeiner wrote:
On Friday, 18 August 2017 at 10:50:28 UTC, Moritz Maxeiner wrote:
On Friday, 18 August 2017 at 10:06:04 UTC, Vino wrote:
On Friday, 18 August 2017 at 08:34:39 UTC, ikod wrote:
On Friday, 18 August 2017 at 08:00:26 UTC, Vino.B wrote:
Hi All,

I have written a small program to just list the directories, but when i run the program each time i am getting different output, hence request you help, below is the code

[...]

Do you expect some strict execution order when you run 'parallel' foreach?

Yes, the order of execution should be the same as the order of the directory provided to scan.

Then you cannot parallelize the work[1], use:

---
auto dFiles = dirEntries(Dirlist[i], SpanMode.shallow).filter!(a => a.isDir);
foreach (d; dFiles)
{
    writefln("%-63s %.20s", d, d.timeCreated().toSimpleString);
}
---

[1] You cannot parallelize computations that depend on each other, which you make yours do by requiring a specific order of execution.

Small correction: You *could* parallelize the conversion to string `d.timeCreated().toSimpleString`, but then you'd need to merge the resulting sets of strings generated in each work unit to regain the original order.

Hi,
Thank you very much, it worked and need one more help, with the below line i am able to list all directories which contains the pattern *DND*, now i need the revers, list all the directories expect those containing the pattern *DND*.

dirEntries(i, SpanMode.shallow).filter!(a => a.isDir).filter!(a => globMatch(a.baseName, "*DND*"))

Reply via email to