eventq.hh (8232:b28d06a175be) | eventq.hh (8581:56f97760eadd) |
---|---|
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; --- 135 unchanged lines hidden (view full) --- 144 protected: 145 /// Accessor for flags. 146 Flags 147 getFlags() const 148 { 149 return flags & PublicRead; 150 } 151 | 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; --- 135 unchanged lines hidden (view full) --- 144 protected: 145 /// Accessor for flags. 146 Flags 147 getFlags() const 148 { 149 return flags & PublicRead; 150 } 151 |
152 Flags 153 getFlags(Flags _flags) const | 152 bool 153 isFlagSet(Flags _flags) const |
154 { 155 assert(_flags.noneSet(~PublicRead)); 156 return flags.isSet(_flags); 157 } 158 | 154 { 155 assert(_flags.noneSet(~PublicRead)); 156 return flags.isSet(_flags); 157 } 158 |
159 Flags 160 allFlags(Flags _flags) const 161 { 162 assert(_flags.noneSet(~PublicRead)); 163 return flags.allSet(_flags); 164 } 165 | |
166 /// Accessor for flags. 167 void 168 setFlags(Flags _flags) 169 { 170 assert(_flags.noneSet(~PublicWrite)); 171 flags.set(_flags); 172 } 173 --- 68 unchanged lines hidden (view full) --- 242 243 /// Maximum priority 244 static const Priority Maximum_Pri = SCHAR_MAX; 245 246 /* 247 * Event constructor 248 * @param queue that the event gets scheduled on 249 */ | 159 /// Accessor for flags. 160 void 161 setFlags(Flags _flags) 162 { 163 assert(_flags.noneSet(~PublicWrite)); 164 flags.set(_flags); 165 } 166 --- 68 unchanged lines hidden (view full) --- 235 236 /// Maximum priority 237 static const Priority Maximum_Pri = SCHAR_MAX; 238 239 /* 240 * Event constructor 241 * @param queue that the event gets scheduled on 242 */ |
250 Event(Priority p = Default_Pri) 251 : nextBin(NULL), nextInBin(NULL), _priority(p), flags(Initialized) | 243 Event(Priority p = Default_Pri, Flags f = 0) 244 : nextBin(NULL), nextInBin(NULL), _priority(p), 245 flags(Initialized | f) |
252 { | 246 { |
247 assert(f.noneSet(~PublicWrite)); |
|
253#ifndef NDEBUG 254 instance = ++instanceCounter; 255 queue = NULL; 256#endif 257#ifdef EVENTQ_DEBUG 258 whenCreated = curTick(); 259 whenScheduled = 0; 260#endif --- 140 unchanged lines hidden (view full) --- 401 * @todo this assert is a good bug catcher. I need to 402 * make it true again. 403 */ 404 //assert(head->when() >= when && "event scheduled in the past"); 405 serviceOne(); 406 } 407 } 408 | 248#ifndef NDEBUG 249 instance = ++instanceCounter; 250 queue = NULL; 251#endif 252#ifdef EVENTQ_DEBUG 253 whenCreated = curTick(); 254 whenScheduled = 0; 255#endif --- 140 unchanged lines hidden (view full) --- 396 * @todo this assert is a good bug catcher. I need to 397 * make it true again. 398 */ 399 //assert(head->when() >= when && "event scheduled in the past"); 400 serviceOne(); 401 } 402 } 403 |
409 // default: process all events up to 'now' (curTick()) 410 void serviceEvents() { serviceEvents(curTick()); } 411 | |
412 // return true if no events are queued 413 bool empty() const { return head == NULL; } 414 415 void dump() const; 416 | 404 // return true if no events are queued 405 bool empty() const { return head == NULL; } 406 407 void dump() const; 408 |
417 Tick nextEventTime() { return empty() ? curTick() : head->when(); } 418 | |
419 bool debugVerify() const; 420 421#ifndef SWIG 422 virtual void serialize(std::ostream &os); 423 virtual void unserialize(Checkpoint *cp, const std::string §ion); 424#endif 425}; 426 --- 127 unchanged lines hidden (view full) --- 554{ 555 class DelayEvent : public Event 556 { 557 private: 558 T *object; 559 560 public: 561 DelayEvent(T *o) | 409 bool debugVerify() const; 410 411#ifndef SWIG 412 virtual void serialize(std::ostream &os); 413 virtual void unserialize(Checkpoint *cp, const std::string §ion); 414#endif 415}; 416 --- 127 unchanged lines hidden (view full) --- 544{ 545 class DelayEvent : public Event 546 { 547 private: 548 T *object; 549 550 public: 551 DelayEvent(T *o) |
562 : object(o) 563 { this->setFlags(AutoDelete); } | 552 : Event(Default_Pri, AutoDelete), object(o) 553 { } |
564 void process() { (object->*F)(); } 565 const char *description() const { return "delay"; } 566 }; 567 568 eventq->schedule(new DelayEvent(object), when); 569} 570 571template <class T, void (T::* F)()> --- 33 unchanged lines hidden --- | 554 void process() { (object->*F)(); } 555 const char *description() const { return "delay"; } 556 }; 557 558 eventq->schedule(new DelayEvent(object), when); 559} 560 561template <class T, void (T::* F)()> --- 33 unchanged lines hidden --- |