diff --git a/core/scheduler.h b/core/scheduler.h index c6cadd5ff..6b2697598 100644 --- a/core/scheduler.h +++ b/core/scheduler.h @@ -155,6 +155,23 @@ class Scheduler { return wakeup_queue_; } + // Selects the next TrafficClass to run. + LeafTrafficClass *Next(uint64_t tsc) { + WakeTCs(tsc); + + if (!root_ || root_->blocked()) { + // Nothing to schedule anywhere. + return nullptr; + } + + TrafficClass *c = root_; + while (c->policy_ != POLICY_LEAF) { + c = c->PickNextChild(); + } + + return static_cast *>(c); + } + protected: // Starts at the given class and attempts to unblock classes on the path // towards the root. @@ -215,7 +232,7 @@ class DefaultScheduler : public Scheduler { resource_arr_t usage; // Schedule. - LeafTrafficClass *leaf = Next(this->checkpoint_); + LeafTrafficClass *leaf = Scheduler::Next(this->checkpoint_); uint64_t now; if (leaf) { @@ -251,23 +268,6 @@ class DefaultScheduler : public Scheduler { this->checkpoint_ = now; } - - // Selects the next TrafficClass to run. - LeafTrafficClass *Next(uint64_t tsc) { - this->WakeTCs(tsc); - - if (!this->root_ || this->root_->blocked()) { - // Nothing to schedule anywhere. - return nullptr; - } - - TrafficClass *c = this->root_; - while (c->policy_ != POLICY_LEAF) { - c = c->PickNextChild(); - } - - return static_cast *>(c); - } }; template @@ -309,7 +309,7 @@ class ExperimentalScheduler : public Scheduler { resource_arr_t usage; // Schedule. - LeafTrafficClass *leaf = Next(this->checkpoint_); + LeafTrafficClass *leaf = Scheduler::Next(this->checkpoint_); uint64_t now; if (leaf) { @@ -356,23 +356,6 @@ class ExperimentalScheduler : public Scheduler { this->checkpoint_ = now; } - - // Selects the next TrafficClass to run. - LeafTrafficClass *Next(uint64_t tsc) { - this->WakeTCs(tsc); - - if (!this->root_ || this->root_->blocked()) { - // Nothing to schedule anywhere. - return nullptr; - } - - TrafficClass *c = this->root_; - while (c->policy_ != POLICY_LEAF) { - c = c->PickNextChild(); - } - - return static_cast *>(c); - } }; } // namespace bess