mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Issue #77 Break dependency of loghandler and tokenbucket on time and units
This commit is contained in:
@@ -156,9 +156,8 @@ namespace BlackMisc
|
||||
else if (statusMessage.getMessage().startsWith(QStringLiteral("QCommandLineParser: option not defined"))) { statusMessage.setSeverity(CStatusMessage::SeverityDebug); }
|
||||
}
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
auto bucket = m_tokenBuckets.find(statusMessage);
|
||||
if (bucket == m_tokenBuckets.end()) { bucket = m_tokenBuckets.insert(statusMessage, { { 5, CTime(1, CTimeUnit::s()), 1 }, 0 }); }
|
||||
if (bucket == m_tokenBuckets.end()) { bucket = m_tokenBuckets.insert(statusMessage, { { 5, 1000, 1 }, 0 }); }
|
||||
if (! bucket->first.tryConsume())
|
||||
{
|
||||
bucket->second++;
|
||||
|
||||
@@ -7,18 +7,11 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/tokenbucket.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
CTokenBucket::CTokenBucket(int capacity, const CTime &interval, int numTokensToRefill)
|
||||
: m_capacity(capacity), m_numTokensToRefill(numTokensToRefill), m_intervalMs(interval.value(CTimeUnit::ms()))
|
||||
{}
|
||||
|
||||
CTokenBucket::CTokenBucket(int capacity, qint64 intervalMs, int numTokensToRefill)
|
||||
: m_capacity(capacity), m_numTokensToRefill(numTokensToRefill), m_intervalMs(intervalMs)
|
||||
{}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define BLACKMISC_TOKENBUCKET_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/pq/time.h"
|
||||
#include <QDateTime>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -25,9 +24,6 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CTokenBucket
|
||||
{
|
||||
public:
|
||||
//! Constructor for given replenishment policy
|
||||
CTokenBucket(int capacity, const PhysicalQuantities::CTime &interval, int numTokensToRefill);
|
||||
|
||||
//! Constructor for given replenishment policy
|
||||
CTokenBucket(int capacity, qint64 intervalMs, int numTokensToRefill);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user