Skip to content

Commit

Permalink
rename rtimer to timer (#48128)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges authored Feb 19, 2025
1 parent b7cd15d commit f3a2f3c
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 133 deletions.
4 changes: 2 additions & 2 deletions src/core/core.pri
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ HEADERS += \
$$PWD/config.h \
$$PWD/timerwheel.h \
$$PWD/jwt.h \
$$PWD/rtimer.h \
$$PWD/timer.h \
$$PWD/defercall.h \
$$PWD/socketnotifier.h \
$$PWD/eventloop.h \
Expand All @@ -79,7 +79,7 @@ SOURCES += \
$$PWD/config.cpp \
$$PWD/timerwheel.cpp \
$$PWD/jwt.cpp \
$$PWD/rtimer.cpp \
$$PWD/timer.cpp \
$$PWD/defercall.cpp \
$$PWD/socketnotifier.cpp \
$$PWD/eventloop.cpp \
Expand Down
6 changes: 3 additions & 3 deletions src/core/qzmqsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <boost/signals2.hpp>
#include "rust/bindings.h"
#include "qzmqcontext.h"
#include "rtimer.h"
#include "timer.h"
#include "socketnotifier.h"

using Connection = boost::signals2::scoped_connection;
Expand Down Expand Up @@ -372,7 +372,7 @@ class Socket::Private
bool canWrite, canRead;
QList< QList<QByteArray> > pendingWrites;
int pendingWritten;
std::unique_ptr<RTimer> updateTimer;
std::unique_ptr<Timer> updateTimer;
Connection updateTimerConnection;
bool pendingUpdate;
int shutdownWaitTime;
Expand Down Expand Up @@ -421,7 +421,7 @@ class Socket::Private
sn_read->activated.connect(boost::bind(&Private::sn_read_activated, this));
sn_read->setEnabled(true);

updateTimer = std::make_unique<RTimer>();
updateTimer = std::make_unique<Timer>();
updateTimerConnection = updateTimer->timeout.connect(boost::bind(&Private::update_timeout, this));
updateTimer->setSingleShot(true);
}
Expand Down
18 changes: 9 additions & 9 deletions src/core/statsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "httpheaders.h"
#include "simplehttpserver.h"
#include "zutil.h"
#include "rtimer.h"
#include "timer.h"

// make this somewhat big since PUB is lossy
#define OUT_HWM 200000
Expand Down Expand Up @@ -425,10 +425,10 @@ class StatsManager::Private : public QObject
QHash<QByteArray, Report*> reports;
Counts combinedCounts;
Report combinedReport;
std::unique_ptr<RTimer> activityTimer;
std::unique_ptr<RTimer> reportTimer;
std::unique_ptr<RTimer> refreshTimer;
std::unique_ptr<RTimer> externalConnectionsMaxTimer;
std::unique_ptr<Timer> activityTimer;
std::unique_ptr<Timer> reportTimer;
std::unique_ptr<Timer> refreshTimer;
std::unique_ptr<Timer> externalConnectionsMaxTimer;
Connection activityTimerConnection;
Connection reportTimerConnection;
Connection refreshTimerConnection;
Expand All @@ -455,15 +455,15 @@ class StatsManager::Private : public QObject
currentSubscriptionRefreshBucket(0),
wheel(TimerWheel((_connectionsMax * 2) + _subscriptionsMax))
{
activityTimer = std::make_unique<RTimer>();
activityTimer = std::make_unique<Timer>();
activityTimerConnection = activityTimer->timeout.connect(boost::bind(&Private::activity_timeout, this));
activityTimer->setSingleShot(true);

refreshTimer = std::make_unique<RTimer>();
refreshTimer = std::make_unique<Timer>();
refreshTimerConnection = refreshTimer->timeout.connect(boost::bind(&Private::refresh_timeout, this));
refreshTimer->start(REFRESH_INTERVAL);

externalConnectionsMaxTimer = std::make_unique<RTimer>();
externalConnectionsMaxTimer = std::make_unique<Timer>();
externalConnectionsMaxTimerConnection = externalConnectionsMaxTimer->timeout.connect(boost::bind(&Private::externalConnectionsMax_timeout, this));
externalConnectionsMaxTimer->start(EXTERNAL_CONNECTIONS_MAX_INTERVAL);

Expand Down Expand Up @@ -606,7 +606,7 @@ class StatsManager::Private : public QObject
{
if(reportInterval > 0 && !reportTimer)
{
reportTimer = std::make_unique<RTimer>();
reportTimer = std::make_unique<Timer>();
reportTimerConnection = reportTimer->timeout.connect(boost::bind(&Private::report_timeout, this));
reportTimer->start(reportInterval);
}
Expand Down
36 changes: 18 additions & 18 deletions src/core/rtimer.cpp → src/core/timer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2021 Fanout, Inc.
* Copyright (C) 2024 Fastly, Inc.
* Copyright (C) 2024-2025 Fastly, Inc.
*
* This file is part of Pushpin.
*
Expand All @@ -21,7 +21,7 @@
* $FANOUT_END_LICENSE$
*/

#include "rtimer.h"
#include "timer.h"

#include <assert.h>
#include <QDateTime>
Expand Down Expand Up @@ -54,7 +54,7 @@ class TimerManager : public QObject
public:
TimerManager(int capacity, QObject *parent = 0);

int add(int msec, RTimer *r);
int add(int msec, Timer *r);
void remove(int key);

private slots:
Expand All @@ -81,7 +81,7 @@ TimerManager::TimerManager(int capacity, QObject *parent) :
t_->setSingleShot(true);
}

int TimerManager::add(int msec, RTimer *r)
int TimerManager::add(int msec, Timer *r)
{
qint64 currentTime = QDateTime::currentMSecsSinceEpoch();

Expand Down Expand Up @@ -130,7 +130,7 @@ void TimerManager::t_timeout()
break;
}

RTimer *r = (RTimer *)expired.userData;
Timer *r = (Timer *)expired.userData;

r->timerReady();
}
Expand Down Expand Up @@ -173,42 +173,42 @@ void TimerManager::updateTimeout(qint64 currentTime)

static thread_local TimerManager *g_manager = 0;

RTimer::RTimer() :
Timer::Timer() :
singleShot_(false),
interval_(0),
timerId_(-1)
{
}

RTimer::~RTimer()
Timer::~Timer()
{
stop();
}

bool RTimer::isActive() const
bool Timer::isActive() const
{
return (timerId_ >= 0);
}

void RTimer::setSingleShot(bool singleShot)
void Timer::setSingleShot(bool singleShot)
{
singleShot_ = singleShot;
}

void RTimer::setInterval(int msec)
void Timer::setInterval(int msec)
{
interval_ = msec;
}

void RTimer::start(int msec)
void Timer::start(int msec)
{
setInterval(msec);
start();
}

void RTimer::start()
void Timer::start()
{
// must call RTimer::init first
// must call Timer::init first
assert(g_manager);

stop();
Expand All @@ -219,7 +219,7 @@ void RTimer::start()
timerId_ = id;
}

void RTimer::stop()
void Timer::stop()
{
if(timerId_ >= 0)
{
Expand All @@ -231,7 +231,7 @@ void RTimer::stop()
}
}

void RTimer::timerReady()
void Timer::timerReady()
{
timerId_ = -1;

Expand All @@ -243,17 +243,17 @@ void RTimer::timerReady()
timeout();
}

void RTimer::init(int capacity)
void Timer::init(int capacity)
{
assert(!g_manager);

g_manager = new TimerManager(capacity);
}

void RTimer::deinit()
void Timer::deinit()
{
delete g_manager;
g_manager = 0;
}

#include "rtimer.moc"
#include "timer.moc"
14 changes: 7 additions & 7 deletions src/core/rtimer.h → src/core/timer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2021 Fanout, Inc.
* Copyright (C) 2024 Fastly, Inc.
* Copyright (C) 2024-2025 Fastly, Inc.
*
* This file is part of Pushpin.
*
Expand All @@ -21,8 +21,8 @@
* $FANOUT_END_LICENSE$
*/

#ifndef RTIMER_H
#define RTIMER_H
#ifndef TIMER_H
#define TIMER_H

#include <qobject.h>
#include <boost/signals2.hpp>
Expand All @@ -31,13 +31,13 @@ using Signal = boost::signals2::signal<void()>;

class TimerManager;

class RTimer : public QObject
class Timer : public QObject
{
Q_OBJECT

public:
RTimer();
~RTimer();
Timer();
~Timer();

bool isActive() const;

Expand All @@ -50,7 +50,7 @@ class RTimer : public QObject
// initialization is thread local
static void init(int capacity);

// only call if there are no active RTimers
// only call if there are no active timers
static void deinit();

Signal timeout;
Expand Down
6 changes: 3 additions & 3 deletions src/core/zhttpmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "log.h"
#include "zutil.h"
#include "logutil.h"
#include "rtimer.h"
#include "timer.h"

#define OUT_HWM 100
#define IN_HWM 100
Expand Down Expand Up @@ -102,7 +102,7 @@ class ZhttpManager::Private : public QObject
QHash<ZWebSocket::Rid, ZWebSocket*> clientSocksByRid;
QHash<ZWebSocket::Rid, ZWebSocket*> serverSocksByRid;
QList<ZWebSocket*> serverPendingSocks;
std::unique_ptr<RTimer> refreshTimer;
std::unique_ptr<Timer> refreshTimer;
QHash<void*, KeepAliveRegistration*> keepAliveRegistrations;
QSet<KeepAliveRegistration*> sessionRefreshBuckets[ZHTTP_REFRESH_BUCKETS];
int currentSessionRefreshBucket;
Expand All @@ -123,7 +123,7 @@ class ZhttpManager::Private : public QObject
doBind(false),
currentSessionRefreshBucket(0)
{
refreshTimer = std::make_unique<RTimer>();
refreshTimer = std::make_unique<Timer>();
refreshTimerConnection = refreshTimer->timeout.connect(boost::bind(&Private::refresh_timeout, this));
}

Expand Down
14 changes: 7 additions & 7 deletions src/core/zhttprequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "zhttpresponsepacket.h"
#include "bufferlist.h"
#include "log.h"
#include "rtimer.h"
#include "timer.h"
#include "defercall.h"
#include "zhttpmanager.h"
#include "uuidutil.h"
Expand Down Expand Up @@ -100,9 +100,9 @@ class ZhttpRequest::Private : public QObject
bool writableChanged;
bool errored;
ErrorCondition errorCondition;
RTimer *expireTimer;
RTimer *keepAliveTimer;
RTimer *finishTimer;
Timer *expireTimer;
Timer *keepAliveTimer;
Timer *finishTimer;
bool multi;
bool quiet;
Connection expTimerConnection;
Expand Down Expand Up @@ -143,11 +143,11 @@ class ZhttpRequest::Private : public QObject
multi(false),
quiet(false)
{
expireTimer = new RTimer;
expireTimer = new Timer;
expTimerConnection = expireTimer->timeout.connect(boost::bind(&Private::expire_timeout, this));
expireTimer->setSingleShot(true);

keepAliveTimer = new RTimer;
keepAliveTimer = new Timer;
keepAliveTimerConnection = keepAliveTimer->timeout.connect(boost::bind(&Private::keepAlive_timeout, this));
}

Expand Down Expand Up @@ -296,7 +296,7 @@ class ZhttpRequest::Private : public QObject

if(timeout > 0)
{
finishTimer = new RTimer;
finishTimer = new Timer;
finishTimerConnection = finishTimer->timeout.connect(boost::bind(&Private::expire_timeout, this));
finishTimer->setSingleShot(true);
finishTimer->start(timeout);
Expand Down
6 changes: 3 additions & 3 deletions src/core/zrpcrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "zrpcmanager.h"
#include "uuidutil.h"
#include "log.h"
#include "rtimer.h"
#include "timer.h"
#include "defercall.h"

using Connection = boost::signals2::scoped_connection;
Expand All @@ -51,7 +51,7 @@ class ZrpcRequest::Private : public QObject
QVariant result;
ErrorCondition condition;
QByteArray conditionString;
std::unique_ptr<RTimer> timer;
std::unique_ptr<Timer> timer;
Connection timerConnection;
DeferCall deferCall;

Expand Down Expand Up @@ -157,7 +157,7 @@ class ZrpcRequest::Private : public QObject

if(manager->timeout() >= 0)
{
timer = std::make_unique<RTimer>();
timer = std::make_unique<Timer>();
timerConnection = timer->timeout.connect(boost::bind(&Private::timer_timeout, this));
timer->setSingleShot(true);
timer->start(manager->timeout());
Expand Down
Loading

0 comments on commit f3a2f3c

Please sign in to comment.