OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 INRIA | 3 * Copyright (c) 2009 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 Scheduler::Event | 134 Scheduler::Event |
135 CalendarScheduler::PeekNext (void) const | 135 CalendarScheduler::PeekNext (void) const |
136 { | 136 { |
137 NS_LOG_FUNCTION (this); | 137 NS_LOG_FUNCTION (this); |
138 NS_ASSERT (!IsEmpty ()); | 138 NS_ASSERT (!IsEmpty ()); |
139 uint32_t i = m_lastBucket; | 139 uint32_t i = m_lastBucket; |
140 uint64_t bucketTop = m_bucketTop; | 140 uint64_t bucketTop = m_bucketTop; |
141 Scheduler::Event minEvent; | 141 Scheduler::Event minEvent; |
142 minEvent.impl = 0; | 142 minEvent.impl = 0; |
143 minEvent.key.m_ts = ~0; | 143 minEvent.key.m_ts = UINT64_MAX; |
144 minEvent.key.m_uid = ~0; | 144 minEvent.key.m_uid = UINT32_MAX; |
145 minEvent.key.m_context = 0; | 145 minEvent.key.m_context = 0; |
146 do | 146 do |
147 { | 147 { |
148 if (!m_buckets[i].empty ()) | 148 if (!m_buckets[i].empty ()) |
149 { | 149 { |
150 Scheduler::Event next = m_buckets[i].front (); | 150 Scheduler::Event next = m_buckets[i].front (); |
151 if (next.key.m_ts < bucketTop) | 151 if (next.key.m_ts < bucketTop) |
152 { | 152 { |
153 return next; | 153 return next; |
154 } | 154 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 CalendarScheduler::ResizeDown (void) | 267 CalendarScheduler::ResizeDown (void) |
268 { | 268 { |
269 NS_LOG_FUNCTION (this); | 269 NS_LOG_FUNCTION (this); |
270 | 270 |
271 if (m_qSize < m_nBuckets / 2) | 271 if (m_qSize < m_nBuckets / 2) |
272 { | 272 { |
273 Resize (m_nBuckets / 2); | 273 Resize (m_nBuckets / 2); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 uint32_t | 277 uint64_t |
278 CalendarScheduler::CalculateNewWidth (void) | 278 CalendarScheduler::CalculateNewWidth (void) |
279 { | 279 { |
280 NS_LOG_FUNCTION (this); | 280 NS_LOG_FUNCTION (this); |
281 | 281 |
282 if (m_qSize < 2) | 282 if (m_qSize < 2) |
283 { | 283 { |
284 return 1; | 284 return 1; |
285 } | 285 } |
286 uint32_t nSamples; | 286 uint32_t nSamples; |
287 if (m_qSize <= 5) | 287 if (m_qSize <= 5) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 cur++; | 348 cur++; |
349 next++; | 349 next++; |
350 } | 350 } |
351 | 351 |
352 totalSeparation *= 3; | 352 totalSeparation *= 3; |
353 totalSeparation = std::max (totalSeparation, (uint64_t)1); | 353 totalSeparation = std::max (totalSeparation, (uint64_t)1); |
354 return totalSeparation; | 354 return totalSeparation; |
355 } | 355 } |
356 void | 356 void |
357 CalendarScheduler::DoResize (uint32_t newSize, uint32_t newWidth) | 357 CalendarScheduler::DoResize (uint32_t newSize, uint64_t newWidth) |
358 { | 358 { |
359 NS_LOG_FUNCTION (this << newSize << newWidth); | 359 NS_LOG_FUNCTION (this << newSize << newWidth); |
360 | 360 |
361 Bucket *oldBuckets = m_buckets; | 361 Bucket *oldBuckets = m_buckets; |
362 uint32_t oldNBuckets = m_nBuckets; | 362 uint32_t oldNBuckets = m_nBuckets; |
363 Init (newSize, newWidth, m_lastPrio); | 363 Init (newSize, newWidth, m_lastPrio); |
364 | 364 |
365 for (uint32_t i = 0; i < oldNBuckets; i++) | 365 for (uint32_t i = 0; i < oldNBuckets; i++) |
366 { | 366 { |
367 Bucket::iterator end = oldBuckets[i].end (); | 367 Bucket::iterator end = oldBuckets[i].end (); |
368 for (Bucket::iterator j = oldBuckets[i].begin (); j != end; ++j) | 368 for (Bucket::iterator j = oldBuckets[i].begin (); j != end; ++j) |
369 { | 369 { |
370 DoInsert (*j); | 370 DoInsert (*j); |
371 } | 371 } |
372 } | 372 } |
373 delete [] oldBuckets; | 373 delete [] oldBuckets; |
374 } | 374 } |
375 void | 375 void |
376 CalendarScheduler::Resize (uint32_t newSize) | 376 CalendarScheduler::Resize (uint32_t newSize) |
377 { | 377 { |
378 NS_LOG_FUNCTION (this << newSize); | 378 NS_LOG_FUNCTION (this << newSize); |
379 | 379 |
380 // PrintInfo (); | 380 // PrintInfo (); |
381 uint32_t newWidth = CalculateNewWidth (); | 381 uint64_t newWidth = CalculateNewWidth (); |
382 DoResize (newSize, newWidth); | 382 DoResize (newSize, newWidth); |
383 } | 383 } |
384 | 384 |
385 } // namespace ns3 | 385 } // namespace ns3 |
OLD | NEW |