Skip to content

Commit

Permalink
refactor(timer): remove GuiTickTimer and SuspendableTimer (unused)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Aug 10, 2023
1 parent 67f3810 commit 9b18a0e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
64 changes: 0 additions & 64 deletions src/util/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,67 +46,3 @@ mixxx::Duration Timer::elapsed(bool report) {
}
return elapsedTime;
}

SuspendableTimer::SuspendableTimer(QString key,
Stat::ComputeFlags compute)
: Timer(std::move(key), compute) {
}

void SuspendableTimer::start() {
m_leapTime = mixxx::Duration::fromSeconds(0);
Timer::start();
}

mixxx::Duration SuspendableTimer::suspend() {
m_leapTime += m_time.elapsed();
m_running = false;
return m_leapTime;
}

void SuspendableTimer::go() {
Timer::start();
}

mixxx::Duration SuspendableTimer::elapsed(bool report) {
m_leapTime += m_time.elapsed();
if (report) {
// Ignore the report if it crosses the experiment boundary.
Experiment::Mode oldMode = Stat::modeFromFlags(m_compute);
if (oldMode == Experiment::mode()) {
Stat::track(m_key, Stat::DURATION_NANOSEC, m_compute,
m_leapTime.toIntegerNanos());
}
}
return m_leapTime;
}

GuiTickTimer::GuiTickTimer(QObject* pParent)
: QObject(pParent),
m_pGuiTick(make_parented<ControlProxy>(
"[Master]", "guiTickTime", this)),
m_bActive(false) {
}

void GuiTickTimer::start(mixxx::Duration duration) {
m_pGuiTick->connectValueChanged(this, &GuiTickTimer::slotGuiTick);
m_interval = duration;
m_lastUpdate = mixxx::Duration::fromSeconds(0);
m_bActive = true;
}

void GuiTickTimer::stop() {
m_pGuiTick->disconnect();
m_bActive = false;
m_interval = mixxx::Duration::fromSeconds(0);
m_lastUpdate = mixxx::Duration::fromSeconds(0);
}

void GuiTickTimer::slotGuiTick(double) {
if (m_bActive) {
auto time = mixxx::Time::elapsed();
if (time - m_lastUpdate >= m_interval) {
m_lastUpdate = time;
emit timeout();
}
}
}
38 changes: 0 additions & 38 deletions src/util/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,6 @@ class Timer {
PerformanceTimer m_time;
};

class SuspendableTimer : public Timer {
public:
SuspendableTimer(QString,
Stat::ComputeFlags compute = kDefaultComputeFlags);
void start();
mixxx::Duration suspend();
void go();
mixxx::Duration elapsed(bool report);

private:
mixxx::Duration m_leapTime;
};

class ScopedTimer {
public:
ScopedTimer(QStringView key,
Expand Down Expand Up @@ -94,28 +81,3 @@ class ScopedTimer {
char m_timerMem[sizeof(Timer)];
bool m_cancel;
};

// A timer that provides a similar API to QTimer but uses render events from the
// VSyncThread as its source of timing events. This means the timer cannot fire
// at a rate faster than the user's configured waveform FPS.
class GuiTickTimer : public QObject {
Q_OBJECT
public:
GuiTickTimer(QObject* pParent);

void start(mixxx::Duration interval);
bool isActive() const { return m_bActive; }
void stop();

signals:
void timeout();

private slots:
void slotGuiTick(double v);

private:
parented_ptr<ControlProxy> m_pGuiTick;
mixxx::Duration m_interval;
mixxx::Duration m_lastUpdate;
bool m_bActive;
};

0 comments on commit 9b18a0e

Please sign in to comment.