SIMLIB/C++
3.07
|
CQ implementation of calendar. More...
Public Member Functions | |
virtual void | ScheduleAt (Entity *p, double t) override |
enqueue More... | |
virtual Entity * | Get (Entity *p) override |
dequeue More... | |
virtual Entity * | GetFirst () override |
dequeue first More... | |
virtual void | clear (bool destroy=false) override |
remove all More... | |
virtual const char * | Name () override |
virtual void | debug_print () override |
for debugging only More... | |
void | visualize (const char *msg) |
CalendarQueue::visualize – output suitable for Gnuplot. More... | |
![]() | |
bool | Empty () const |
unsigned | Size () const |
double | MinTime () const |
time of activation of first item More... | |
Static Public Member Functions | |
static CalendarQueue * | create () |
create calendar instance More... | |
![]() | |
static Calendar * | instance () |
create/get single instance (singleton) More... | |
static bool | instance_exists () |
check if the instance exists More... | |
Private Types | |
typedef CalendarListImplementation | BucketList |
Private Member Functions | |
bool | list_impl () |
int | time2bucket (double t) |
Convert time to bucket number. More... | |
double | time2bucket_top (double t) |
Compute bucket top limit. More... | |
double | estimate_bucket_width () |
compute new bucket width — EXPERIMENTAL More... | |
void | switchtocq () |
switch to calendar queue implementation More... | |
void | switchtolist () |
switch to list implementation More... | |
CalendarQueue () | |
Initialize calendar queue. More... | |
~CalendarQueue () | |
Destroy calendar queue. More... | |
void | Resize (int grow=0) |
Resize bucket array. More... | |
void | SearchMinTime (double starttime) |
compute new mintime More... | |
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 | |
![]() | |
void | SetMinTime (double t) |
set cache for faster access More... | |
Calendar () | |
virtual | ~Calendar () |
clear is called in derived class dtr More... | |
![]() | |
static void | delete_instance () |
destroy single instance More... | |
![]() | |
unsigned | _size |
number of scheduled items More... | |
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.
|
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(), Dprintf, simlib3::Calendar::Empty(), last_dequeue_time, list, list_impl(), nbuckets, ndelta, numop, simlib3::Calendar::SetMinTime(), simlib3::SIMLIB_MAXTIME, and sumdelta.
Referenced by ~CalendarQueue().
|
inlinestatic |
create calendar instance
Definition at line 596 of file calendar.cc.
References simlib3::Calendar::delete_instance(), Dprintf, and simlib3::SIMLIB_atexit().
Referenced by simlib3::Calendar::delete_instance(), simlib3::Calendar::instance(), and simlib3::SetCalendar().
|
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(), 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(), simlib3::EmptyCalendar, simlib3::EntityIsNotScheduled, simlib3::CalendarListImplementation::first_time(), simlib3::Entity::Idle(), list, list_impl(), 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(), simlib3::EmptyCalendar, simlib3::CalendarListImplementation::first_time(), last_dequeue_time, list, list_impl(), 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.
Referenced by clear(), Get(), GetFirst(), ScheduleAt(), and visualize().
|
inlineoverridevirtual |
Implements simlib3::Calendar.
Definition at line 604 of file calendar.cc.
References simlib3::Calendar::debug_print().
|
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(), MAX_OP, simlib3::Calendar::MinTime(), simlib3::SimObject::Name(), numop, Resize(), simlib3::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::Calendar::Empty(), simlib3::CalendarListImplementation::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(), 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.
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 simlib3::Calendar::clear(), simlib3::Calendar::Get(), simlib3::Calendar::GetFirst(), simlib3::Calendar::ScheduleAt(), 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::Calendar::_instance, 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(), and visualize().
|
private |
Definition at line 549 of file calendar.cc.
Referenced by clear(), debug_print(), estimate_bucket_width(), Get(), GetFirst(), 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(), 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().