Skip to content

fileHandler in combination with threading

When using a threaded fileHandler (e.g. collated) the code does not know to wait for a file being written before trying to read it. This happens e.g. in topoSet (reading a set that has just been written), decomposePar (reading the decomposed mesh to decompose the fields)

Solutions:

  • switch off threading altogether. This is what is currently done.
  • have IFstream know about currently written files. This would require all IFstream to go through the fileHandler, so use fileHandler().NewIFstream instead of IFstream everywhere.
  • since it is only a few applications that have this make sure to reset the fileHandler.

This last solution has been implemented by a new 'flush()' method on all fileHandlers which clears out any cached data (e.g. time directories) and waits for all file operations to finish.