Skip to content

Commit 8340a8a

Browse files
committed
new alarm ctor and poll() ret val
1 parent 7778eb6 commit 8340a8a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

kit/freq/freq.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ class Freq
169169
//assert(m_pTimer);
170170
set(t);
171171
}
172+
explicit Alarm(Time t, Timeline* timer, std::function<void()> func):
173+
m_pTimer(timer),
174+
m_pCallback(std::make_shared<boost::signals2::signal<void()>>())
175+
//m_pTimer(timer ? timer : Freq::get().accumulator())
176+
{
177+
//assert(m_pTimer);
178+
set(t);
179+
m_pCallback->connect(func);
180+
}
181+
172182

173183
virtual ~Alarm() {}
174184

@@ -267,11 +277,13 @@ class Freq
267277
void connect(std::function<void()> cb) {
268278
m_pCallback->connect(std::move(cb));
269279
}
270-
void poll() {
280+
bool poll() {
271281
if(elapsed()) {
272282
(*m_pCallback)();
273283
m_pCallback->disconnect_all_slots();
284+
return true;
274285
}
286+
return false;
275287
}
276288

277289
float fraction_left() const

0 commit comments

Comments
 (0)