Add EventDriverTimers.isUnique.
This commit is contained in:
parent
956978cc79
commit
6851776358
|
@ -422,6 +422,9 @@ interface EventDriverTimers {
|
||||||
Returns `false` $(I iff) the last reference was removed by this call.
|
Returns `false` $(I iff) the last reference was removed by this call.
|
||||||
*/
|
*/
|
||||||
bool releaseRef(TimerID descriptor);
|
bool releaseRef(TimerID descriptor);
|
||||||
|
|
||||||
|
/// Determines if the given timer's reference count equals one.
|
||||||
|
bool isUnique(TimerID descriptor) const;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EventDriverWatchers {
|
interface EventDriverWatchers {
|
||||||
|
|
|
@ -88,6 +88,7 @@ final class LoopTimeoutTimerDriver : EventDriverTimers {
|
||||||
assert(tm !is null);
|
assert(tm !is null);
|
||||||
tm.id = id;
|
tm.id = id;
|
||||||
tm.refCount = 1;
|
tm.refCount = 1;
|
||||||
|
tm.timeout = long.max;
|
||||||
m_timers[id] = tm;
|
m_timers[id] = tm;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +139,7 @@ final class LoopTimeoutTimerDriver : EventDriverTimers {
|
||||||
|
|
||||||
final override void wait(TimerID timer, TimerCallback callback)
|
final override void wait(TimerID timer, TimerCallback callback)
|
||||||
{
|
{
|
||||||
|
import eventcore.internal.utils; print("emit timer");
|
||||||
assert(!m_timers[timer].callback, "Calling wait() no a timer that is already waiting.");
|
assert(!m_timers[timer].callback, "Calling wait() no a timer that is already waiting.");
|
||||||
m_timers[timer].callback = callback;
|
m_timers[timer].callback = callback;
|
||||||
}
|
}
|
||||||
|
@ -179,6 +181,12 @@ final class LoopTimeoutTimerDriver : EventDriverTimers {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final bool isUnique(TimerID descriptor)
|
||||||
|
const {
|
||||||
|
if (descriptor == TimerID.init) return false;
|
||||||
|
return m_timers[descriptor].refCount == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TimerSlot {
|
struct TimerSlot {
|
||||||
|
|
Loading…
Reference in a new issue