Changeset 28:bac3a3382c4a in xplcommon
- Timestamp:
- 01/02/13 08:53:57 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/testlocsock.cc
r21 r28 40 40 #include <xplcommon/WritingBuffer.h> 41 41 #include <xplcommon/WaitableEvent.h> 42 #include <xplcommon/PseudoRandom.h> 42 43 43 44 #include <cstdlib> … … 61 62 using xplcommon::WritingBuffer; 62 63 using xplcommon::WaitableEvent; 64 using xplcommon::PseudoRandom; 63 65 64 66 using std::min; … … 72 74 static const size_t minToWrite = 2076; 73 75 static const size_t maxToWrite = 1345670; 74 static const size_t rangeToWrite = maxToWrite - minToWrite;75 76 76 77 static const size_t reportingInterval = 10000; 77 78 78 static const int sleepThreshold = static_cast<int>( RAND_MAX * 0.99);79 static const int sleepRemainder = RAND_MAX - sleepThreshold;79 static const int sleepThreshold = static_cast<int>(PseudoRandom::MAX * 0.99); 80 static const int sleepRemainder = PseudoRandom::MAX - sleepThreshold; 80 81 static const unsigned minSleep = 10; 81 82 static const unsigned maxSleep = 250; … … 92 93 bool toQuit = false; 93 94 95 PseudoRandom random(seed); 94 96 while(!toQuit) { 95 #if TARGET_API_POSIX 96 int r = rand_r(&seed); 97 #endif 98 #if TARGET_API_WIN32 99 int r = rand(); 100 #endif 101 size_t toWrite = minToWrite + 102 static_cast<size_t>( static_cast<double>(r) * 103 rangeToWrite / RAND_MAX ); 97 size_t toWrite = random.nextUnsigned(maxToWrite, minToWrite); 104 98 105 99 size_t lastWriteLength = 0; … … 204 198 } 205 199 206 #if TARGET_API_POSIX 207 r = rand_r(&seed); 208 #endif 209 #if TARGET_API_WIN32 210 r = rand(); 211 #endif 200 int r = random.next(); 212 201 if (r>=sleepThreshold) { 213 202 unsigned toSleep = minSleep +
Note:
See TracChangeset
for help on using the changeset viewer.