Safely writing to the same file in parallel foreach loop

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Nov 14 15:44:02 PST 2012


On 11/14/2012 10:17 PM, Jonathan M Davis wrote:
> I would point out though that given how expensive disk writes are, unless
> you're doing a lot of work within the parallel foreach loop, there's a good
> chance that it would be more efficient to use std.concurrency and pass the
> writes to another thread to do the writing.

In the application I have in mind, there is a LOT of work that would be done 
within the parallel foreach loop -- we're talking at least 20 minutes' solid 
processing before the file write takes place, so this seems an appropriate 
approach given how simple it is.

That said, the separate-thread-for-writes is a nice concept and I'll have a play 
with it.  Concurrency is something where I'm very much a beginner, so I'm very 
open to all suggestions -- thanks very much for this one!



More information about the Digitalmars-d-learn mailing list