#include <scheduler.h>
Inheritance diagram for scheduler:


Public Member Functions | |
| scheduler (actor_mapper &mapper, int time_per_activation, int maximum_weight, int max_actor_weight, int snooze_interval=64) | |
| constructs a scheduling mechanism given its timing and constraints. | |
| virtual | ~scheduler () |
| IMPLEMENT_CLASS_NAME ("scheduler") | |
| const int_averager & | processing_durations () const |
| the average times taken in process_schedule. | |
| const int_averager & | activation_durations () const |
| the average times taken in activating the item. | |
| const int_averager & | item_durations () const |
| the average times taken for a complete scheduling of items. | |
| const int_averager & | bandwidths () const |
| averages the speed of transmission for completed items. | |
| int | snooze_interval () const |
| the pause time between runs, as specified in constructor. | |
| void | reset_stats () |
| clears all current duration and speed measurements from the scheduler. | |
| outcome | add (schedulable *to_schedule, bool single_file) |
| places an item "to_schedule" in the scheduling queue. | |
| void | start_scheduling () |
| void | stop_scheduling () |
| outcome | remove_by_id (scheduling_id id) |
| removes an item in the schedule with the "id" specified. | |
| outcome | remove_by_actor (int actor_id) |
| removes all items in the schedule tied to the actor with "actor_id". | |
| outcome | mark_dead (scheduling_id to_mark) |
| marks the item specified by "to_mark" as a dead item. | |
| void | filter_missing_actors (const int_set &valid_actors) |
| dumps any items whose actor is not listed in the set of "valid_actors". | |
| void | schedule_text_form (string_array &info, int indent=0) |
| returns a line of information for each object in the schedule. | |
| void | pending_text_form (istring &info, int indent=0) |
| prints the single-file items that are still pending into "info". | |
| void | memory_text_form (istring &info, int indent=2) |
| drops all information about schedule memory usage into "info". | |
| schedule_iterator * | open_iterator (common::list_positions where=common::HEAD) |
| provides an iterator with write access on the schedule. | |
| schedule_iterator * | find (scheduling_id to_find) |
| returns an iterator pointing at the item specified by "to_find". | |
| void | close_iterator (schedule_iterator *&to_close) |
| eliminates an iterator and frees the schedule for use again. | |
| const schedulable * | active_item (schedule_iterator &to_use) const |
| returns a pointer to the schedulable that is currently active. | |
| bool | items_scheduled (schedule_iterator &to_use, int actor) |
| returns true if any scheduled items could be found for "actor". | |
| void | zap (schedule_iterator &to_use) |
| eliminates the schedulable at the position specified by "to_use". | |
Friends | |
| class | schedule_driver |
| allowed to touch our privates. | |
This keeps track of the current items to schedule and activates them according to their periodicities.
Definition at line 42 of file scheduler.h.
| scheduler::scheduler | ( | actor_mapper & | mapper, | |
| int | time_per_activation, | |||
| int | maximum_weight, | |||
| int | max_actor_weight, | |||
| int | snooze_interval = 64 | |||
| ) |
constructs a scheduling mechanism given its timing and constraints.
the "mapper" provides the actors that operate on scheduled items. if there are any synchronization issues related to the schedule_actors, then the mapper must deal with them. the "time_per_activation" is the amount of time any one item's activation is allowed to last. the "maximum_weight" is the largest amount of space the schedule is allowed to consume. if it's zero, then there is no overall size limit. the "max_actor_weight" is a similar limit on the largest any one schedule_actor's queue is allowed to get. if it is zero, then no limit is enforced per schedule_actor. the "snooze_interval" is the interval between runs of the scheduler; this is the fastest that items can be processed once the queue goes empty.
Definition at line 158 of file scheduler.cpp.
| scheduler::~scheduler | ( | ) | [virtual] |
Definition at line 176 of file scheduler.cpp.
References nodes::safe_list_write_iterator::access(), nodes::safe_list::close_writer(), nodes::safe_list::empty(), FUNCDEF, nodes::safe_list_write_iterator::is_tail(), array< contents >::length(), LIFT_WEIGHT_AND_VERIFY, LOG, nodes::safe_list::open_writer(), pending_text_form(), log_base::platform_ending(), istring::reset(), schedule_text_form(), WHACK(), and nodes::safe_list::zap().
| scheduler::IMPLEMENT_CLASS_NAME | ( | "scheduler" | ) |
| const int_averager & scheduler::processing_durations | ( | ) | const |
the average times taken in process_schedule.
this includes all of the phases of scheduling (preprocessing, activation, postprocessing, and destruction) plus any administrative overhead incurred by the implementation.
Definition at line 231 of file scheduler.cpp.
| const int_averager & scheduler::activation_durations | ( | ) | const |
the average times taken in activating the item.
this is just the time spent within our schedulable object's virtual processing function(?).
Definition at line 234 of file scheduler.cpp.
| const int_averager & scheduler::item_durations | ( | ) | const |
the average times taken for a complete scheduling of items.
this is measured from queue entry to queue exit.
Definition at line 225 of file scheduler.cpp.
| const int_averager & scheduler::bandwidths | ( | ) | const |
averages the speed of transmission for completed items.
this is their weight (bytes consumed) divided by their overall duration in the schedule, measured in kilobytes per second.
Definition at line 228 of file scheduler.cpp.
| int scheduler::snooze_interval | ( | ) | const [inline] |
the pause time between runs, as specified in constructor.
Definition at line 84 of file scheduler.h.
| void scheduler::reset_stats | ( | ) |
clears all current duration and speed measurements from the scheduler.
any existing schedulables will still retain their own metrics, but the main scheduler reports will be dumped.
| outcome scheduler::add | ( | schedulable * | to_schedule, | |
| bool | single_file | |||
| ) |
places an item "to_schedule" in the scheduling queue.
the item's actor will be invoked to pass the item through various phases of its scheduling. note that once the schedulable is given to the scheduler, its destruction will be managed by the scheduler; do not destroy it yourself. NO_SPACE will be returned if the schedule has hit its upper limit. in cases where "to_schedule" couldn't be added, it is whacked; thus there is _never_ any reason for a caller to touch "to_schedule" after invoking this method. the "single_file" parameter indicates whether items scheduled for the same actor should be paused until any others for that actor have completed.
Definition at line 333 of file scheduler.cpp.
References schedulable::actor_id(), scheduling_common::BAD_INPUT, close_iterator(), nodes::safe_list::close_writer(), mailbox::drop_off(), find(), FUNCDEF, nodes::safe_list::insert(), schedulable::item_id(), item_statistics::last_outcome, LOG, scheduling_common::NO_SPACE, scheduling_common::OKAY, memory_limiter::okay_allocation(), nodes::safe_list::open_writer(), unique_id< uniquifier >::raw_id(), istring::SPRINTF, schedulable::stats(), schedulable::weight(), and WHACK().
| void scheduler::start_scheduling | ( | ) |
| void scheduler::stop_scheduling | ( | ) |
Definition at line 242 of file scheduler.cpp.
| outcome scheduler::remove_by_id | ( | scheduling_id | id | ) |
removes an item in the schedule with the "id" specified.
NOT_FOUND will be returned if that id cannot be found. this is not safe to call during execution of the schedule_actor's callbacks; use mark_dead() instead.
Definition at line 876 of file scheduler.cpp.
References nodes::safe_list_write_iterator::access(), mailbox::apply(), nodes::safe_list::close_writer(), FUNCDEF, nodes::safe_list_write_iterator::is_tail(), LIFT_WEIGHT_AND_VERIFY, LOG, nodes::safe_list_write_iterator::next(), scheduling_common::OKAY, nodes::safe_list::open_writer(), unique_id< uniquifier >::raw_id(), removal_applier(), and nodes::safe_list::zap().
| outcome scheduler::remove_by_actor | ( | int | actor_id | ) |
removes all items in the schedule tied to the actor with "actor_id".
this is commonly used to clear any items associated with an actor that is about to be destroyed.
Definition at line 718 of file scheduler.cpp.
References nodes::safe_list_write_iterator::access(), mailbox::close_out(), nodes::safe_list::close_writer(), FUNCDEF, nodes::safe_list_write_iterator::is_tail(), LIFT_WEIGHT_AND_VERIFY, nodes::safe_list_write_iterator::next(), scheduling_common::OKAY, nodes::safe_list::open_writer(), and nodes::safe_list::zap().
| outcome scheduler::mark_dead | ( | scheduling_id | to_mark | ) |
marks the item specified by "to_mark" as a dead item.
on the next scheduling go-round, it will be removed. this is safe to call even when the item is active. the item will still have its postprocess method invoked when it leaves the schedule.
Definition at line 708 of file scheduler.cpp.
References schedule_iterator::access(), close_iterator(), schedulable::expiration(), find(), FUNCDEF, scheduling_common::NOT_FOUND, scheduling_common::OKAY, and heartbeat::reset().
| void scheduler::filter_missing_actors | ( | const int_set & | valid_actors | ) |
dumps any items whose actor is not listed in the set of "valid_actors".
Definition at line 928 of file scheduler.cpp.
References nodes::safe_list_write_iterator::access(), mailbox::apply(), nodes::safe_list::close_writer(), filter_actor_applier(), FUNCDEF, nodes::safe_list_write_iterator::is_tail(), LIFT_WEIGHT_AND_VERIFY, LOG, basis::set< contents >::member(), nodes::safe_list_write_iterator::next(), nodes::safe_list::open_writer(), and nodes::safe_list::zap().
| void scheduler::schedule_text_form | ( | string_array & | info, | |
| int | indent = 0 | |||
| ) |
returns a line of information for each object in the schedule.
the "indent" value is the number of spaces prefixed to each entry.
Referenced by ~scheduler().
| void scheduler::pending_text_form | ( | istring & | info, | |
| int | indent = 0 | |||
| ) |
prints the single-file items that are still pending into "info".
the items shown here are ones that have been added to an actor's queue as single-file; each item must be processed before the next one can be. this prints a blank line after each entry. the "info" string is not reset; the new information is appeneded to it.
Referenced by ~scheduler().
| void scheduler::memory_text_form | ( | istring & | info, | |
| int | indent = 2 | |||
| ) |
drops all information about schedule memory usage into "info".
Definition at line 763 of file scheduler.cpp.
References memory_limiter::text_form().
| schedule_iterator * scheduler::open_iterator | ( | common::list_positions | where = common::HEAD |
) |
provides an iterator with write access on the schedule.
this must be shut down using close_schedule_iterator().
Definition at line 244 of file scheduler.cpp.
References schedule_iterator::_hidden_iterator, common::HEAD, NIL, nodes::safe_list::open_writer(), and common::TAIL.
| schedule_iterator * scheduler::find | ( | scheduling_id | to_find | ) |
returns an iterator pointing at the item specified by "to_find".
if it does not exist in the schedule, NIL is returned.
Definition at line 272 of file scheduler.cpp.
References schedule_iterator::_hidden_iterator, nodes::safe_list_write_iterator::access(), nodes::safe_list::close_writer(), nodes::safe_list_write_iterator::is_tail(), nodes::safe_list_write_iterator::next(), NIL, and nodes::safe_list::open_writer().
Referenced by add(), and mark_dead().
| void scheduler::close_iterator | ( | schedule_iterator *& | to_close | ) |
eliminates an iterator and frees the schedule for use again.
the pointer holding the iterator will be reset to nil.
Definition at line 254 of file scheduler.cpp.
References schedule_iterator::_hidden_iterator, nodes::safe_list::close_writer(), NIL, and WHACK().
Referenced by add(), and mark_dead().
| const schedulable* scheduler::active_item | ( | schedule_iterator & | to_use | ) | const |
returns a pointer to the schedulable that is currently active.
if no item is active, then NIL is returned. this is a read-only view of that current item. note that one must have already opened an iterator "to_use" before calling this function.
Referenced by items_scheduled().
| bool scheduler::items_scheduled | ( | schedule_iterator & | to_use, | |
| int | actor | |||
| ) |
returns true if any scheduled items could be found for "actor".
note that this might include the active_item(). also, the iterator "to_use" will be left in a random place after this call.
Definition at line 288 of file scheduler.cpp.
References schedule_iterator::access(), active_item(), schedulable::actor_id(), schedule_iterator::is_tail(), schedule_iterator::jump_head(), and schedule_iterator::next().
| void scheduler::zap | ( | schedule_iterator & | to_use | ) |
eliminates the schedulable at the position specified by "to_use".
the postprocess function is not called.
Definition at line 264 of file scheduler.cpp.
References schedule_iterator::_hidden_iterator, schedule_iterator::access(), schedulable::actor_id(), FUNCDEF, LIFT_WEIGHT_AND_VERIFY, schedulable::weight(), and nodes::safe_list::zap().
friend class schedule_driver [friend] |
1.5.1