Deleted Added
sdiff udiff text old ( 5769:e53bdd0e4bf1 ) new ( 5774:a7ce656e32a0 )
full compact
1/*
2 * Copyright (c) 2000-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 63 unchanged lines hidden (view full) ---

72 static const FlagsType PublicRead = 0x003f;
73 static const FlagsType PublicWrite = 0x001d;
74 static const FlagsType Squashed = 0x0001;
75 static const FlagsType Scheduled = 0x0002;
76 static const FlagsType AutoDelete = 0x0004;
77 static const FlagsType AutoSerialize = 0x0008;
78 static const FlagsType IsExitEvent = 0x0010;
79 static const FlagsType IsMainQueue = 0x0020;
80
81 private:
82 // The event queue is now a linked list of linked lists. The
83 // 'nextBin' pointer is to find the bin, where a bin is defined as
84 // when+priority. All events in the same bin will be stored in a
85 // second linked list (a stack) maintained by the 'nextInBin'
86 // pointer. The list will be accessed in LIFO order. The end
87 // result is that the insert/removal in 'nextBin' is

--- 152 unchanged lines hidden (view full) ---

240 Event(Priority p = Default_Pri)
241 : nextBin(NULL), nextInBin(NULL), _priority(p)
242 {
243#ifndef NDEBUG
244 instance = ++instanceCounter;
245 queue = NULL;
246#endif
247#ifdef EVENTQ_DEBUG
248 whenCreated = curTick;
249 whenScheduled = 0;
250#endif
251 }
252
253 virtual ~Event();
254 virtual const std::string name() const;
255

--- 208 unchanged lines hidden (view full) ---

464 void process() { (object->*F)(); }
465};
466
467inline void
468EventQueue::schedule(Event *event, Tick when)
469{
470 assert(when >= curTick);
471 assert(!event->scheduled());
472
473 event->setWhen(when, this);
474 insert(event);
475 event->flags.set(Event::Scheduled);
476 if (this == &mainEventQueue)
477 event->flags.set(Event::IsMainQueue);
478 else
479 event->flags.clear(Event::IsMainQueue);
480
481 if (DTRACE(Event))
482 event->trace("scheduled");
483}
484
485inline void
486EventQueue::deschedule(Event *event)
487{
488 assert(event->scheduled());
489
490 remove(event);
491
492 event->flags.clear(Event::Squashed);
493 event->flags.clear(Event::Scheduled);
494
495 if (event->flags.isSet(Event::AutoDelete))
496 delete event;
497
498 if (DTRACE(Event))
499 event->trace("descheduled");
500}
501
502inline void
503EventQueue::reschedule(Event *event, Tick when, bool always)
504{
505 assert(when >= curTick);
506 assert(always || event->scheduled());
507
508 if (event->scheduled())
509 remove(event);
510
511 event->setWhen(when, this);
512 insert(event);
513 event->flags.clear(Event::Squashed);
514 event->flags.set(Event::Scheduled);

--- 50 unchanged lines hidden ---