Deleted Added
sdiff udiff text old ( 7058:5c7416199efd ) new ( 7059:4fb4eeb5f412 )
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;

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

63class Event : public Serializable, public FastAlloc
64{
65 friend class EventQueue;
66
67 protected:
68 typedef short FlagsType;
69 typedef ::Flags<FlagsType> Flags;
70
71 static const FlagsType PublicRead = 0x003f;
72 static const FlagsType PublicWrite = 0x001d;
73 static const FlagsType Squashed = 0x0001;
74 static const FlagsType Scheduled = 0x0002;
75 static const FlagsType AutoDelete = 0x0004;
76 static const FlagsType AutoSerialize = 0x0008;
77 static const FlagsType IsExitEvent = 0x0010;
78 static const FlagsType IsMainQueue = 0x0020;
79#ifdef EVENTQ_DEBUG
80 static const FlagsType Initialized = 0xf000;
81#endif
82
83 public:
84 typedef int8_t Priority;
85
86 private:
87 // The event queue is now a linked list of linked lists. The
88 // 'nextBin' pointer is to find the bin, where a bin is defined as
89 // when+priority. All events in the same bin will be stored in a
90 // second linked list (a stack) maintained by the 'nextInBin'

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

141 getFlags() const
142 {
143 return flags & PublicRead;
144 }
145
146 Flags
147 getFlags(Flags _flags) const
148 {
149 assert(flags.noneSet(~PublicRead));
150 return flags.isSet(_flags);
151 }
152
153 Flags
154 allFlags(Flags _flags) const
155 {
156 assert(_flags.noneSet(~PublicRead));
157 return flags.allSet(_flags);

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

237 /// Maximum priority
238 static const Priority Maximum_Pri = SCHAR_MAX;
239
240 /*
241 * Event constructor
242 * @param queue that the event gets scheduled on
243 */
244 Event(Priority p = Default_Pri)
245 : nextBin(NULL), nextInBin(NULL), _priority(p)
246 {
247#ifndef NDEBUG
248 instance = ++instanceCounter;
249 queue = NULL;
250#endif
251#ifdef EVENTQ_DEBUG
252 flags.set(Initialized);
253 whenCreated = curTick;
254 whenScheduled = 0;
255#endif
256 }
257
258 virtual ~Event();
259 virtual const std::string name() const;
260

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

473 }
474};
475
476inline void
477EventQueue::schedule(Event *event, Tick when)
478{
479 assert((UTick)when >= (UTick)curTick);
480 assert(!event->scheduled());
481#ifdef EVENTQ_DEBUG
482 assert((event->flags & Event::Initialized) == Event::Initialized);
483#endif
484
485 event->setWhen(when, this);
486 insert(event);
487 event->flags.set(Event::Scheduled);
488 if (this == &mainEventQueue)
489 event->flags.set(Event::IsMainQueue);
490 else
491 event->flags.clear(Event::IsMainQueue);
492
493 if (DTRACE(Event))
494 event->trace("scheduled");
495}
496
497inline void
498EventQueue::deschedule(Event *event)
499{
500 assert(event->scheduled());
501#ifdef EVENTQ_DEBUG
502 assert((event->flags & Event::Initialized) == Event::Initialized);
503#endif
504
505 remove(event);
506
507 event->flags.clear(Event::Squashed);
508 event->flags.clear(Event::Scheduled);
509
510 if (event->flags.isSet(Event::AutoDelete))
511 delete event;
512
513 if (DTRACE(Event))
514 event->trace("descheduled");
515}
516
517inline void
518EventQueue::reschedule(Event *event, Tick when, bool always)
519{
520 assert(when >= curTick);
521 assert(always || event->scheduled());
522#ifdef EVENTQ_DEBUG
523 assert((event->flags & Event::Initialized) == Event::Initialized);
524#endif
525
526 if (event->scheduled())
527 remove(event);
528
529 event->setWhen(when, this);
530 insert(event);
531 event->flags.clear(Event::Squashed);
532 event->flags.set(Event::Scheduled);

--- 56 unchanged lines hidden ---