Changes between Initial Version and Version 1 of Ticket #6223
- Timestamp:
- Nov 16, 2015, 10:04:46 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #6223
- Property Status new → assigned
-
Ticket #6223 – Description
initial v1 1 In r15574, youput 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?1 In 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? 2 2 3 3 e.g. … … 9 9 (unsigned int)(CPLGetPID() & 0xFFFFFFFFU), nTempFileCounter++ ); 10 10 }}} 11 Would become this .11 Would become this: 12 12 {{{#!c++ 13 13 static int nTempFileCounter = 0; 14 14 CPLString osFilename; 15 15 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 ) ); 18 18 }}} 19 19