Skip to content

Commit 380c263

Browse files
committed
src:arduino-timer: size() function
Timer.size() returns the number of active tasks in the timer.
1 parent a5ecffe commit 380c263

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/arduino-timer.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ class Timer {
168168
return ticks;
169169
}
170170

171+
/* Number of active tasks in the timer */
172+
size_t
173+
size() const
174+
{
175+
size_t s = 0;
176+
177+
timer_foreach_const_task(task) {
178+
if (task->handler) ++s;
179+
}
180+
181+
return s;
182+
}
183+
171184
Timer() : ctr(0), tasks{} {}
172185

173186
private:

0 commit comments

Comments
 (0)