diff --git a/libs/main/thread/pitimer.cpp b/libs/main/thread/pitimer.cpp index 71c1ccc0..611e9852 100644 --- a/libs/main/thread/pitimer.cpp +++ b/libs/main/thread/pitimer.cpp @@ -263,7 +263,7 @@ bool PITimer::start(PISystemTime interval) { bool PITimer::start(PISystemTime interval, std::function func) { if (isRunning()) stopAndWait(); setInterval(interval); - setSlot(func); + setSlot(std::move(func)); return start(); } @@ -275,7 +275,7 @@ void PITimer::stopAndWait(PISystemTime timeout) { void PITimer::addDelimiter(int delim, std::function func) { - delims << Delimiter(func, delim); + delims << Delimiter(std::move(func), delim); } diff --git a/libs/main/thread/pitimer.h b/libs/main/thread/pitimer.h index 5780a998..4ed9f089 100644 --- a/libs/main/thread/pitimer.h +++ b/libs/main/thread/pitimer.h @@ -126,11 +126,17 @@ public: //! \~english Sets a tick callback that ignores the delimiter value. //! \~russian Устанавливает обратный вызов тика, игнорирующий значение делителя. - void setSlot(std::function func) { ret_func = std::move(func); } + void setSlot(std::function func) { + ret_func_delim = nullptr; + ret_func = std::move(func); + } //! \~english Sets a tick callback that receives the current delimiter value. //! \~russian Устанавливает обратный вызов тика, принимающий текущее значение делителя. - void setSlot(std::function func) { ret_func_delim = std::move(func); } + void setSlot(std::function func) { + ret_func = nullptr; + ret_func_delim = std::move(func); + } //! \~english Enables locking of the internal mutex around tick processing. //! \~russian Включает блокировку внутреннего мьютекса вокруг обработки тиков. @@ -139,7 +145,8 @@ public: EVENT_HANDLER0(void, unlock) { mutex_.unlock(); } //! \~english Returns whether the timer drains queued delivery for itself as performer on each main tick. By default \b true. - //! \~russian Возвращает, должен ли таймер обрабатывать отложенную доставку для себя как исполнителя на каждом основном тике. По умолчанию \b true. + //! \~russian Возвращает, должен ли таймер обрабатывать отложенную доставку для себя как исполнителя на каждом основном тике. По + //! умолчанию \b true. bool isCallQueuedEvents() const { return callEvents; } //! \~english Enables or disables queued-delivery draining through \a maybeCallQueuedEvents() on each main tick. @@ -219,7 +226,7 @@ public: protected: struct PIP_EXPORT Delimiter { Delimiter(std::function func_ = nullptr, int delim_ = 1) { - func = func_; + func = std::move(func_); delim = delim_; } std::function func; @@ -243,7 +250,7 @@ protected: PIMutex mutex_; PISystemTime m_interval, m_interval_x5; PISystemTime m_time_next; - std::function ret_func = nullptr; + std::function ret_func = nullptr; std::function ret_func_delim = nullptr; PIVector delims; PIConditionVariable event;