|
SIMLIB/C++ 3.09
|
CQ implementation of calendar. More...


Public Member Functions | |
| virtual void | ScheduleAt (Entity *p, double t) override |
| enqueue | |
| virtual Entity * | Get (Entity *p) override |
| dequeue | |
| virtual Entity * | GetFirst () override |
| dequeue first | |
| virtual void | clear (bool destroy=false) override |
| remove all | |
| virtual const char * | Name () override |
| virtual void | debug_print () override |
| for debugging only | |
| void | visualize (const char *msg) |
| CalendarQueue::visualize – output suitable for Gnuplot. | |
Public Member Functions inherited from simlib3::Calendar | |
| bool | Empty () const |
| unsigned | Size () const |
| virtual void | ScheduleAt (Entity *e, double t)=0 |
| enqueue | |
| virtual Entity * | GetFirst ()=0 |
| dequeue first | |
| virtual Entity * | Get (Entity *e)=0 |
| dequeue | |
| virtual void | clear (bool destroy_entities=false)=0 |
| remove all scheduled entities | |
| virtual const char * | Name ()=0 |
| virtual void | debug_print ()=0 |
| for debugging only | |
| double | MinTime () const |
| time of activation of first item | |
Static Public Member Functions | |
| static CalendarQueue * | create () |
| create calendar instance | |
Static Public Member Functions inherited from simlib3::Calendar | |
| static Calendar * | instance () |
| create/get single instance (singleton) | |
| static bool | instance_exists () |
| check if the instance exists | |
Private Types | |
| typedef CalendarListImplementation | BucketList |
Private Member Functions | |
| bool | list_impl () |
| int | time2bucket (double t) |
| Convert time to bucket number. | |
| double | time2bucket_top (double t) |
| Compute bucket top limit. | |
| double | estimate_bucket_width () |
| compute new bucket width — EXPERIMENTAL | |
| void | switchtocq () |
| switch to calendar queue implementation | |
| void | switchtolist () |
| switch to list implementation | |
| CalendarQueue () | |
| Initialize calendar queue. | |
| ~CalendarQueue () | |
| Destroy calendar queue. | |
| void | Resize (int grow=0) |
| Resize bucket array. | |
| void | SearchMinTime (double starttime) |
| compute new mintime | |
Private Attributes | |
| BucketList * | buckets |
| BucketList | list |
| unsigned | nbuckets |
| unsigned | hi_bucket_mark |
| unsigned | low_bucket_mark |
| unsigned | nextbucket |
| unsigned | numop |
| double | bucket_width |
| double | buckettop |
| double | last_dequeue_time |
| double | sumdelta |
| unsigned | ndelta |
Additional Inherited Members | |
Protected Member Functions inherited from simlib3::Calendar | |
| void | SetMinTime (double t) |
| set cache for faster access | |
| Calendar () | |
| virtual | ~Calendar () |
| clear is called in derived class dtr | |
Static Protected Member Functions inherited from simlib3::Calendar | |
| static void | delete_instance () |
| destroy single instance | |
Protected Attributes inherited from simlib3::Calendar | |
| unsigned | _size |
| number of scheduled items | |
CQ implementation of calendar.
Definition at line 547 of file calendar.cc.
|
private |
Definition at line 548 of file calendar.cc.
|
private |
Initialize calendar queue.
Definition at line 625 of file calendar.cc.
References Dprintf, simlib3::Calendar::SetMinTime(), and simlib3::SIMLIB_MAXTIME.
Referenced by create().
|
private |
Destroy calendar queue.
Definition at line 1121 of file calendar.cc.
References simlib3::allocator, simlib3::EventNoticeAllocator::clear(), clear(), and Dprintf.
|
overridevirtual |
remove all
clear calendar queue
Implements simlib3::Calendar.
Definition at line 1089 of file calendar.cc.
References simlib3::Calendar::_size, buckets, simlib3::CalendarListImplementation::clear(), clear(), Dprintf, simlib3::Calendar::Empty(), last_dequeue_time, list, list_impl(), nbuckets, ndelta, numop, simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_MAXTIME, and sumdelta.
Referenced by clear(), and ~CalendarQueue().
|
inlinestatic |
create calendar instance
Definition at line 596 of file calendar.cc.
References CalendarQueue(), simlib3::Calendar::delete_instance(), Dprintf, and simlib3::SIMLIB_atexit().
Referenced by simlib3::Calendar::instance().
|
overridevirtual |
for debugging only
Implements simlib3::Calendar.
Definition at line 1157 of file calendar.cc.
References buckets, simlib3::CalendarListImplementation::debug_print(), simlib3::Calendar::instance_exists(), nbuckets, and simlib3::Print().
|
private |
compute new bucket width — EXPERIMENTAL
Definition at line 837 of file calendar.cc.
References simlib3::CalendarListImplementation::begin(), bucket_width, buckets, Dprintf, simlib3::CalendarListImplementation::end(), simlib3::Calendar::MinTime(), simlib3::MUL_PAR, nbuckets, ndelta, simlib3::SIMLIB_error(), simlib3::SIMLIB_MAXTIME, sumdelta, t, time2bucket(), and time2bucket_top().
Referenced by Resize().
dequeue
remove entity e from calendar
called only if rescheduling
Implements simlib3::Calendar.
Definition at line 735 of file calendar.cc.
References simlib3::Calendar::_size, simlib3::Entity::ActivationTime(), buckets, simlib3::Calendar::Empty(), EmptyCalendar, EntityIsNotScheduled, simlib3::CalendarListImplementation::first_time(), simlib3::Entity::Idle(), list, list_impl(), simlib3::LIST_MIN, low_bucket_mark, MAX_OP, simlib3::Calendar::MinTime(), numop, simlib3::CalendarListImplementation::remove(), Resize(), SearchMinTime(), simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_error(), simlib3::SIMLIB_MAXTIME, switchtolist(), t, and time2bucket().
|
overridevirtual |
dequeue first
dequeue
Implements simlib3::Calendar.
Definition at line 683 of file calendar.cc.
References simlib3::Calendar::_size, buckets, simlib3::Calendar::Empty(), EmptyCalendar, simlib3::CalendarListImplementation::first_time(), last_dequeue_time, list, list_impl(), simlib3::LIST_MIN, low_bucket_mark, MAX_OP, simlib3::Calendar::MinTime(), ndelta, nextbucket, numop, simlib3::CalendarListImplementation::remove_first(), Resize(), SearchMinTime(), simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_error(), simlib3::SIMLIB_MAXTIME, sumdelta, switchtolist(), and time2bucket().
|
inlineprivate |
Definition at line 564 of file calendar.cc.
References buckets.
Referenced by clear(), Get(), GetFirst(), ScheduleAt(), and visualize().
|
inlineoverridevirtual |
Implements simlib3::Calendar.
Definition at line 604 of file calendar.cc.
|
private |
Resize bucket array.
Definition at line 920 of file calendar.cc.
References simlib3::Calendar::_size, bucket_width, buckets, simlib3::COEF_PAR, Dprintf, simlib3::CalendarListImplementation::empty(), estimate_bucket_width(), simlib3::CalendarListImplementation::extract_first(), hi_bucket_mark, simlib3::CalendarListImplementation::insert_extracted(), low_bucket_mark, simlib3::MINBUCKETS, nbuckets, numop, simlib3::EventNotice::time, and time2bucket().
Referenced by Get(), GetFirst(), and ScheduleAt().
|
overridevirtual |
enqueue
schedule
Implements simlib3::Calendar.
Definition at line 646 of file calendar.cc.
References simlib3::Calendar::_size, buckets, Dprintf, hi_bucket_mark, simlib3::CalendarListImplementation::insert(), list, list_impl(), simlib3::LIST_MAX, MAX_OP, simlib3::Calendar::MinTime(), simlib3::SimObject::Name(), numop, Resize(), SchedulingBeforeTime, simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_error(), switchtocq(), t, simlib3::Time, and time2bucket().
|
private |
compute new mintime
Definition at line 782 of file calendar.cc.
References bucket_width, buckets, buckettop, simlib3::CalendarListImplementation::empty(), simlib3::Calendar::Empty(), simlib3::CalendarListImplementation::first_time(), nbuckets, nextbucket, simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_error(), simlib3::SIMLIB_MAXTIME, t, time2bucket(), and time2bucket_top().
Referenced by Get(), and GetFirst().
|
private |
switch to calendar queue implementation
Definition at line 1020 of file calendar.cc.
References simlib3::Calendar::_size, simlib3::CalendarListImplementation::begin(), bucket_width, buckets, simlib3::COEF_PAR, simlib3::CalendarListImplementation::empty(), simlib3::CalendarListImplementation::end(), simlib3::CalendarListImplementation::extract_first(), hi_bucket_mark, simlib3::CalendarListImplementation::insert_extracted(), last_dequeue_time, list, low_bucket_mark, simlib3::Calendar::MinTime(), simlib3::MUL_PAR, nbuckets, ndelta, numop, simlib3::SIMLIB_warning(), sumdelta, simlib3::EventNotice::time, and time2bucket().
Referenced by ScheduleAt().
|
private |
switch to list implementation
Definition at line 993 of file calendar.cc.
References buckets, simlib3::CalendarListImplementation::empty(), simlib3::CalendarListImplementation::extract_first(), simlib3::CalendarListImplementation::insert_extracted(), list, and nbuckets.
Referenced by Get(), and GetFirst().
|
inlineprivate |
Convert time to bucket number.
Definition at line 567 of file calendar.cc.
References bucket_width, nbuckets, and t.
Referenced by estimate_bucket_width(), Get(), GetFirst(), Resize(), ScheduleAt(), SearchMinTime(), and switchtocq().
|
inlineprivate |
Compute bucket top limit.
Definition at line 575 of file calendar.cc.
References bucket_width, and t.
Referenced by estimate_bucket_width(), and SearchMinTime().
| void simlib3::CalendarQueue::visualize | ( | const char * | msg | ) |
CalendarQueue::visualize – output suitable for Gnuplot.
Definition at line 1170 of file calendar.cc.
References simlib3::CalendarListImplementation::begin(), bucket_width, buckets, simlib3::Calendar::Empty(), simlib3::CalendarListImplementation::end(), list_impl(), simlib3::Calendar::MinTime(), nbuckets, numop, simlib3::Print(), and simlib3::Calendar::Size().
|
private |
Definition at line 557 of file calendar.cc.
Referenced by estimate_bucket_width(), Resize(), SearchMinTime(), switchtocq(), time2bucket(), time2bucket_top(), and visualize().
|
private |
Definition at line 549 of file calendar.cc.
Referenced by clear(), debug_print(), estimate_bucket_width(), Get(), GetFirst(), list_impl(), Resize(), ScheduleAt(), SearchMinTime(), switchtocq(), switchtolist(), and visualize().
|
private |
Definition at line 558 of file calendar.cc.
Referenced by SearchMinTime().
|
private |
Definition at line 552 of file calendar.cc.
Referenced by Resize(), ScheduleAt(), and switchtocq().
|
private |
Definition at line 559 of file calendar.cc.
Referenced by clear(), GetFirst(), and switchtocq().
|
private |
Definition at line 550 of file calendar.cc.
Referenced by clear(), Get(), GetFirst(), ScheduleAt(), switchtocq(), and switchtolist().
|
private |
Definition at line 553 of file calendar.cc.
Referenced by Get(), GetFirst(), Resize(), and switchtocq().
|
private |
Definition at line 551 of file calendar.cc.
Referenced by clear(), debug_print(), estimate_bucket_width(), Resize(), SearchMinTime(), switchtocq(), switchtolist(), time2bucket(), and visualize().
|
private |
Definition at line 561 of file calendar.cc.
Referenced by clear(), estimate_bucket_width(), GetFirst(), and switchtocq().
|
private |
Definition at line 554 of file calendar.cc.
Referenced by GetFirst(), and SearchMinTime().
|
private |
Definition at line 556 of file calendar.cc.
Referenced by clear(), Get(), GetFirst(), Resize(), ScheduleAt(), switchtocq(), and visualize().
|
private |
Definition at line 560 of file calendar.cc.
Referenced by clear(), estimate_bucket_width(), GetFirst(), and switchtocq().