Added caution about accuracy of the std::clock() function of RateLimitedPolicy under linux and Cygwin environnement.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@781 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
f6e7714eca
commit
1ecc9448b9
1 changed files with 7 additions and 3 deletions
|
@ -166,6 +166,10 @@ namespace Loki
|
|||
* Use the setRate method to set the rate parameters.
|
||||
* default is 10 objects in a second.
|
||||
*/
|
||||
// !! CAUTION !!
|
||||
// The std::clock() function is not quite precise
|
||||
// under linux this policy might not work.
|
||||
// TODO : get a better implementation (platform dependant)
|
||||
class RateLimitedCreation
|
||||
{
|
||||
private:
|
||||
|
@ -177,7 +181,7 @@ namespace Loki
|
|||
|
||||
void cleanVector()
|
||||
{
|
||||
clock_t currentTime = std::clock();
|
||||
clock_t currentTime = clock();
|
||||
D( cout << "currentTime = " << currentTime<< endl; )
|
||||
D( cout << "currentTime - lastUpdate = " << currentTime - lastUpdate<< endl; )
|
||||
if(currentTime - lastUpdate > timeValidity)
|
||||
|
@ -207,7 +211,7 @@ namespace Loki
|
|||
cout << endl;
|
||||
}
|
||||
protected:
|
||||
RateLimitedCreation() : maxCreation(10), timeValidity(CLOCKS_PER_SEC), lastUpdate(std::clock())
|
||||
RateLimitedCreation() : maxCreation(10), timeValidity(CLOCKS_PER_SEC), lastUpdate(clock())
|
||||
{}
|
||||
|
||||
struct Exception : public std::exception
|
||||
|
@ -226,7 +230,7 @@ namespace Loki
|
|||
|
||||
void onCreate()
|
||||
{
|
||||
m_vTimes.push_back(std::clock());
|
||||
m_vTimes.push_back(clock());
|
||||
}
|
||||
|
||||
void onDestroy()
|
||||
|
|
Loading…
Reference in a new issue