title: Create a locked file with boost::interprocess::file_lock
body: <p>I'd like to use <code>boost::interprocess::file_lock</code> to ensure that files that are written to a directory <code>x</code> by process <code>P1</code> are not read by process <code>P2</code> until they are complete.  To do this, I'd like to have <code>P1</code> lock the files with <code>boost::interprocess::file_lock</code> while it's writing them, and then unlock them when it's done.  Then <code>P2</code> can just skip over (and come back to) any files that are locked.</p>
  
  <p>The problem I'm having is that it appears that <code>boost::interprocess::file_lock</code> only lets you lock files that exist.  But if I first create the file, and then lock it, then there's a race condition where:</p>
  
  <ol>
  <li><code>P1</code> creates the file</li>
  <li><code>P2</code> notices the file and starts reading it</li>
  <li><code>P1</code> locks the file</li>
  <li><code>P1</code> writes some data</li>
  <li><code>P2</code> reads some data, gets to the end, and ends up with only part of <code>P1</code>'s output.</li>
  </ol>
  
  <p>So what I'd like to do is create a file and have it be locked as soon as it's created.  Is there a way to do this using <code>boost::interprocess::file_lock</code>?</p>