|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-03-20 07:50:24
At 02:46 AM 3/20/2002, Ross Smith wrote:
>> if (exists(filename)) remove(filename);
>
>Race condition.
Yes, but it is way worse than that. Rather than another thread in your own
program causing the problem, it might be another process. Or another
computer on the other side of the world.
Like all I/O, directory operations are subject to unexpected
errors. Consider the following assert, which may fail even in a
non-threaded environment:
assert( exists( "foo" ) == exists( "foo" ) );
I don't see anything to do about these problems except to warn people that
the problems may occur.
Does anyone have a better idea?
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk