32 #include "QuManager.h"
38 QuManager::QuManager(
int nL1,
int nP1,
int nQ1,
int maxppl1,
39 PacketStore *ps1, StatsModule *sm1)
40 : nL(nL1), nP(nP1), nQ(nQ1),
41 maxppl(maxppl1),
ps(ps1), sm(sm1) {
51 for (
int lnk = 1; lnk <=
nL; lnk++) {
52 lnkInfo[lnk].
vt = 0; setLinkRates(lnk, rs);
56 for (
int qid = 1; qid <
nQ; qid++) {
65 enq_timer =
new Timer(
"QuManager::enq(int, int, uint64_t)");
66 deq_timer =
new Timer(
"QuManager::deq(int&, uint64_t)");
70 QuManager::~QuManager() {
75 cout << *enq_timer << endl;
76 cout << *deq_timer << endl;
77 delete enq_timer;
delete deq_timer;
86 if (
free == 0)
return 0;
101 if (qid == 0)
return;
118 QuInfo& q =
quInfo[qid];
int lnk = q.
lnk;
122 if (
sm->getLinkQlen(lnk) >=
maxppl ||
123 sm->getQlen(qid) >= q.pktLim ||
124 sm->getQbytes(qid) + pleng > q.byteLim) {
130 if (!
active->member(lnk)) {
134 if (now >= d) d = now;
143 uint64_t d = q.nsPerByte; d *= pleng;
144 if (q.minDelta > d) d = q.minDelta;
148 if (!
hset->insert(qid,q.vft,lnk)) {
150 cerr <<
"enq attempt to insert in hset failed qid="
151 << qid <<
" lnk=" << lnk <<
" hset="
152 <<
hset->toString(lnk,s);
158 sm->incQlen(qid,lnk,pleng);
173 while (vl != 0 && now >= d) {
178 if (
active->empty())
return 0;
180 if (now < d)
return 0;
183 int qid =
hset->findMin(lnk);
184 pktx px =
queues->removeFirst(qid);
186 sm->decQlen(qid,lnk,pleng);
192 hset->deleteMin(lnk);
198 int npx =
queues->first(qid);
201 uint64_t d = q.nsPerByte; d *= npleng;
202 if (q.minDelta > d) d = q.minDelta;
204 hset->changeKeyMin(q.vft, lnk);
215 if (
hset->empty(lnk)) {