aboutsummaryrefslogtreecommitdiff
path: root/src/TcpTasks/Updater/scheduleupdater.cpp
blob: 86a8f29a738b2a899cb455b18df8f158650c8bfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "syncupdater.h"

bool SyncUpdater::scheduleUpdater()
{
    // schedule sync X seconds apart (prevent network/cpu spikes)
    connect(&_syncTicker, &QTimer::timeout, this, &SyncUpdater::onSyncTickerAction);
    _syncTicker.setInterval( _graceTime_ms );

    // set update timer
    connect(&_updaterTimer, &QTimer::timeout, [this]
    {
        // reset and start ticker
        _syncIndex = 0;
        _syncTicker.start();
    });

    _updaterTimer.setInterval( _coreObject->Settings.SyncerSettings.syncInterval_s * 1000);
    _updaterTimer.start();

    // complete startup
    _coreObject->Log.logEvent("info", QStringLiteral("sync with other masterservers every %1 seconds")
                            .arg(_coreObject->Settings.SyncerSettings.syncInterval_s));

    // run immediately at startup
    _syncIndex = 0;
    _syncTicker.start();

    return true;
}