Changes between Initial Version and Version 1 of Ticket #6223


Ignore:
Timestamp:
Nov 16, 2015, 10:04:46 AM (9 years ago)
Author:
Kurt Schwehr
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6223

    • Property Status newassigned
  • Ticket #6223 – Description

    initial v1  
    1 In r15574, you put a volatile modifier on nTempFileCounter.  This looks to be protect from multithreaded race cases between callers of CPLGenerateTempFilename where more than one thread might get the same tempfile number.  Would it be better to call CPLAtomicInc and use the result of that?  If so, should I drop the volatile?
     1In r15574, put a volatile modifier on nTempFileCounter.  This looks to be protect from multithreaded race cases between callers of CPLGenerateTempFilename where more than one thread might get the same tempfile number.  Would it be better to call CPLAtomicInc and use the result of that?  If so, should I drop the volatile?
    22
    33e.g.
     
    99                       (unsigned int)(CPLGetPID() & 0xFFFFFFFFU), nTempFileCounter++ );
    1010}}}
    11 Would become this.
     11Would become this:
    1212{{{#!c++
    1313    static int nTempFileCounter = 0;
    1414    CPLString osFilename;
    1515    osFilename.Printf( "%s%u_%d", pszStem,
    16                        static_cast<unsigned int>( CPLGetPID() & 0xFFFFFFFFU),
    17                        CPLAtomicInc(nTempFileCounter) );
     16                       static_cast<unsigned int>( CPLGetPID() & 0xFFFFFFFFU ),
     17                       CPLAtomicInc( nTempFileCounter ) );
    1818}}}
    1919