enh(Poco::Util::Timer): Add idle() method to check if timer has any tasks scheduled #4488

This commit is contained in:
Günter Obiltschnig
2024-03-11 10:06:23 +08:00
parent bf164a85a4
commit 072ee8ff9e
3 changed files with 36 additions and 0 deletions

View File

@@ -159,6 +159,9 @@ public:
/// If task execution takes longer than the given interval,
/// further executions are delayed.
bool idle() const;
/// Returns true if the task queue is empty, otherwise false.
template <typename Fn>
static TimerTask::Ptr func(const Fn& fn)
/// Helper function template to use a functor or lambda
@@ -188,6 +191,15 @@ private:
};
//
// inlines
//
inline bool Timer::idle() const
{
return _queue.empty();
}
} } // namespace Poco::Util