in reply to Re: Unique filenames with Time::HiRes
in thread Unique filenames with Time::HiRes
you could just add an additional integer to your filename, so it will be unique. if you start with 0 and go up, you even have the real order.Actually, you would need locking for that, unless you have an atomic test-and-create-file function. Otherwise, you could have two processes which end up in a race condition:generate the filename, test if a file allready exists with this if not create one... you don't need locking for that.
Then what's in the file? Who knows? Probably not what you want.Process 1 checks for filename XXX-42, doesn't exist Process 2 checks for filename XXX-42, doesn't exist Process 1 creates filename XXX-42 and starts writing to it Process 2 opens filename XXX-42 and starts writing to it Process 1 finishes writing to XXX-42 Process 2 finishes writing to XXX-42
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Unique filenames with Time::HiRes
by knoebi (Friar) on Jul 19, 2004 at 15:03 UTC |