http://www.perlmonks.org?node_id=375565


in reply to Re: Unique filenames with Time::HiRes
in thread Unique filenames with Time::HiRes

Hi,

I origionally started this way, however when the daemon starts again it restarted the counter, if any previous files still existed, say at num 1001, and I restarted the daemon again, I would start creating files at number 1. This causes the files to be processed in the incorrect order.

-----
Of all the things I've lost in my life, its my mind I miss the most.
  • Comment on Re^2: Unique filenames with Time::HiRes

Replies are listed 'Best First'.
Re^3: Unique filenames with Time::HiRes
by waswas-fng (Curate) on Jul 19, 2004 at 16:34 UTC
    Why not do a gettimeofday(), test to see if the file name exists, if it does then loop for a few ms, then rinse and repeat until the gettimeofday is unique?


    -Waswas
Re^3: Unique filenames with Time::HiRes
by mutated (Monk) on Jul 20, 2004 at 13:14 UTC
    It's relatively easy though when the daemon is starting for it to check and make sure it is starting above the last number that exists, it can take it's time because until it starts responding to requests for numbers the programs calling it should just block or whatever..


    daN.