eventq.hh (5769:e53bdd0e4bf1) | eventq.hh (5774:a7ce656e32a0) |
---|---|
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; | 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#ifdef EVENTQ_DEBUG 81 static const FlagsType Initialized = 0xf000; 82#endif |
|
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 | 83 84 private: 85 // The event queue is now a linked list of linked lists. The 86 // 'nextBin' pointer is to find the bin, where a bin is defined as 87 // when+priority. All events in the same bin will be stored in a 88 // second linked list (a stack) maintained by the 'nextInBin' 89 // pointer. The list will be accessed in LIFO order. The end 90 // result is that the insert/removal in 'nextBin' is --- 152 unchanged lines hidden (view full) --- 243 Event(Priority p = Default_Pri) 244 : nextBin(NULL), nextInBin(NULL), _priority(p) 245 { 246#ifndef NDEBUG 247 instance = ++instanceCounter; 248 queue = NULL; 249#endif 250#ifdef EVENTQ_DEBUG |
251 flags.set(Initialized); |
|
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()); | 252 whenCreated = curTick; 253 whenScheduled = 0; 254#endif 255 } 256 257 virtual ~Event(); 258 virtual const std::string name() const; 259 --- 208 unchanged lines hidden (view full) --- 468 void process() { (object->*F)(); } 469}; 470 471inline void 472EventQueue::schedule(Event *event, Tick when) 473{ 474 assert(when >= curTick); 475 assert(!event->scheduled()); |
476#ifdef EVENTQ_DEBUG 477 assert((event->flags & Event::Initialized) == Event::Initialized); 478#endif |
|
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()); | 479 480 event->setWhen(when, this); 481 insert(event); 482 event->flags.set(Event::Scheduled); 483 if (this == &mainEventQueue) 484 event->flags.set(Event::IsMainQueue); 485 else 486 event->flags.clear(Event::IsMainQueue); 487 488 if (DTRACE(Event)) 489 event->trace("scheduled"); 490} 491 492inline void 493EventQueue::deschedule(Event *event) 494{ 495 assert(event->scheduled()); |
496#ifdef EVENTQ_DEBUG 497 assert((event->flags & Event::Initialized) == Event::Initialized); 498#endif |
|
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()); | 499 500 remove(event); 501 502 event->flags.clear(Event::Squashed); 503 event->flags.clear(Event::Scheduled); 504 505 if (event->flags.isSet(Event::AutoDelete)) 506 delete event; 507 508 if (DTRACE(Event)) 509 event->trace("descheduled"); 510} 511 512inline void 513EventQueue::reschedule(Event *event, Tick when, bool always) 514{ 515 assert(when >= curTick); 516 assert(always || event->scheduled()); |
517#ifdef EVENTQ_DEBUG 518 assert((event->flags & Event::Initialized) == Event::Initialized); 519#endif |
|
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 --- | 520 521 if (event->scheduled()) 522 remove(event); 523 524 event->setWhen(when, this); 525 insert(event); 526 event->flags.clear(Event::Squashed); 527 event->flags.set(Event::Scheduled); --- 50 unchanged lines hidden --- |