Hi all, just wanting some advice on parallel processing and specifically how to deal with access violations.

I am reading a list of words from a file like this:

auto fileHandle = File("wordlist.txt", "r");

string word;
string[] words;
string[ulong] hashMap;

while ((word = fileHandle.readln()) !is null) {
        words ~= word;
}

Then I'm doing some processing on the words. I want to make this run as quickly as possible so I am doing the processing across the cores of my CPU like this:

foreach (thisWord; parallel(words)) {
        string wordLower = thisWord.strip().toLower();
        ulong key = keyMaker.createKeyForWord(wordLower);

        // hashMap[key] = wordLower;
}

The question is, in the above loop, how can I make the commented out line work without having an access violation. Do I need to use a different data structure? Or rethink what I'm doing?

Thanks in advance.
Andrew.

Reply via email to