Changeset View
Changeset View
Standalone View
Standalone View
libs/global/kis_signal_compressor.cpp
Context not available. | |||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
---|---|---|---|---|---|
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "kis_signal_compressor.h" | 19 | /** | ||
20 | 20 | * KisSignalCompressor will never trigger timeout more often than every \p delay ms, | |||
21 | #include <QTimer> | 21 | * i.e. \p delay ms is a given lower limit defining the highest frequency. | ||
22 | * | ||||
23 | * The current implementation uses a long-running monitor timer to eliminate the | ||||
24 | * overhead incurred by restarting and stopping timers with each signal. The | ||||
25 | * consequence of this is that the given \p delay ms is not always exactly followed. | ||||
26 | * | ||||
27 | * KisSignalCompressor makes the following callback guarantees (0 < err <= 1, with | ||||
28 | * err == 0 if this is the first signal after a while): | ||||
29 | * | ||||
30 | * POSTPONE: | ||||
31 | * - timeout after <= (1 + err) * \p delay ms. | ||||
32 | * FIRST_ACTIVE_POSTPONE_NEXT: | ||||
33 | * - first timeout immediately | ||||
34 | * - postponed timeout after (1 + err) * \p delay ms | ||||
35 | * FIRST_ACTIVE: | ||||
36 | * - first timeout immediately | ||||
37 | * - second timeout after (1 + err) * \p delay ms | ||||
38 | * - after that: \p delay ms | ||||
39 | * FIRST_INACTIVE: | ||||
40 | * - timeout after (1 + err) * \p delay ms | ||||
41 | */ | ||||
22 | 42 | | |||
43 | #include "kis_signal_compressor.h" | ||||
44 | #include "kis_relaxed_timer.h" | ||||
23 | 45 | | |||
24 | KisSignalCompressor::KisSignalCompressor() | 46 | KisSignalCompressor::KisSignalCompressor() | ||
25 | : QObject(0) | 47 | : QObject(0) | ||
26 | , m_timer(new QTimer(this)) | 48 | , m_timer(new KisRelaxedTimer(this)) | ||
27 | , m_mode(UNDEFINED) | 49 | , m_mode(UNDEFINED) | ||
28 | , m_gotSignals(false) | 50 | , m_gotSignals(false) | ||
29 | { | 51 | { | ||
Context not available. | |||||
33 | 55 | | |||
34 | KisSignalCompressor::KisSignalCompressor(int delay, Mode mode, QObject *parent) | 56 | KisSignalCompressor::KisSignalCompressor(int delay, Mode mode, QObject *parent) | ||
35 | : QObject(parent), | 57 | : QObject(parent), | ||
36 | m_timer(new QTimer(this)), | 58 | m_timer(new KisRelaxedTimer(this)), | ||
37 | m_mode(mode), | 59 | m_mode(mode), | ||
38 | m_gotSignals(false) | 60 | m_gotSignals(false) | ||
39 | { | 61 | { | ||
Context not available. |