title: How to wait for a file to exist (and be released)?
body: <p>Is there a library with a function that blocks the caller until a certain file exists and/or is deletable? (Very preferably in the standard C++ libraries or boost.)</p>
  
  <h1>Background</h1>
  
  <p>I'm a C++ newcomer writing a single-threaded application that needs to</p>
  
  <ol>
  <li>Perform some heavy calculations on start up.</li>
  <li>Wait for a certain input file to exist (and be deletable).</li>
  <li>If the file contains a certain instruction, delete it and exit.</li>
  <li>(Else) process it, delete it, and produce an output file.</li>
  <li>Repeat from step 2.</li>
  </ol>
  
  <p>The reason for having steps 2,3 and 5 (instead of just step 1&amp;4 and invoking the application on demand) is that step 1 involves some heavy processing.</p>
  
  <p>I don't want to spend a lot of processor time busy-waiting during step 2, but I also don't want to introduce unnecessary latency by polling for the file's existence infrequently.</p>
  
  <p>What is the right approach here? (Preferably cross-platform: Windows, Linux, OSX.)</p>