eventq: Add some debugging code to the eventq.
This commit is contained in:
parent
19273164da
commit
d0c0c25ebc
2 changed files with 14 additions and 0 deletions
|
@ -59,6 +59,7 @@ Counter Event::instanceCounter = 0;
|
||||||
|
|
||||||
Event::~Event()
|
Event::~Event()
|
||||||
{
|
{
|
||||||
|
assert(!scheduled());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string
|
const std::string
|
||||||
|
|
|
@ -77,6 +77,9 @@ class Event : public Serializable, public FastAlloc
|
||||||
static const FlagsType AutoSerialize = 0x0008;
|
static const FlagsType AutoSerialize = 0x0008;
|
||||||
static const FlagsType IsExitEvent = 0x0010;
|
static const FlagsType IsExitEvent = 0x0010;
|
||||||
static const FlagsType IsMainQueue = 0x0020;
|
static const FlagsType IsMainQueue = 0x0020;
|
||||||
|
#ifdef EVENTQ_DEBUG
|
||||||
|
static const FlagsType Initialized = 0xf000;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The event queue is now a linked list of linked lists. The
|
// The event queue is now a linked list of linked lists. The
|
||||||
|
@ -245,6 +248,7 @@ class Event : public Serializable, public FastAlloc
|
||||||
queue = NULL;
|
queue = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EVENTQ_DEBUG
|
#ifdef EVENTQ_DEBUG
|
||||||
|
flags.set(Initialized);
|
||||||
whenCreated = curTick;
|
whenCreated = curTick;
|
||||||
whenScheduled = 0;
|
whenScheduled = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -469,6 +473,9 @@ EventQueue::schedule(Event *event, Tick when)
|
||||||
{
|
{
|
||||||
assert(when >= curTick);
|
assert(when >= curTick);
|
||||||
assert(!event->scheduled());
|
assert(!event->scheduled());
|
||||||
|
#ifdef EVENTQ_DEBUG
|
||||||
|
assert((event->flags & Event::Initialized) == Event::Initialized);
|
||||||
|
#endif
|
||||||
|
|
||||||
event->setWhen(when, this);
|
event->setWhen(when, this);
|
||||||
insert(event);
|
insert(event);
|
||||||
|
@ -486,6 +493,9 @@ inline void
|
||||||
EventQueue::deschedule(Event *event)
|
EventQueue::deschedule(Event *event)
|
||||||
{
|
{
|
||||||
assert(event->scheduled());
|
assert(event->scheduled());
|
||||||
|
#ifdef EVENTQ_DEBUG
|
||||||
|
assert((event->flags & Event::Initialized) == Event::Initialized);
|
||||||
|
#endif
|
||||||
|
|
||||||
remove(event);
|
remove(event);
|
||||||
|
|
||||||
|
@ -504,6 +514,9 @@ EventQueue::reschedule(Event *event, Tick when, bool always)
|
||||||
{
|
{
|
||||||
assert(when >= curTick);
|
assert(when >= curTick);
|
||||||
assert(always || event->scheduled());
|
assert(always || event->scheduled());
|
||||||
|
#ifdef EVENTQ_DEBUG
|
||||||
|
assert((event->flags & Event::Initialized) == Event::Initialized);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (event->scheduled())
|
if (event->scheduled())
|
||||||
remove(event);
|
remove(event);
|
||||||
|
|
Loading…
Reference in a new issue