diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
commit | dd133c7b24aba128546d24e6042b0e0d46673aaf (patch) | |
tree | 60f82f2f2b708a0fdb6967a7bf1262b435b5e6e0 /src/mem/ruby/buffers/MessageBuffer.hh | |
parent | 3df84fd8a0ce3959c0deb4c206d910fc0d050f47 (diff) | |
download | gem5-dd133c7b24aba128546d24e6042b0e0d46673aaf.tar.xz |
ruby: get rid of PrioHeap and use STL
One big difference is that PrioHeap puts the smallest element at the
top of the heap, whereas stl puts the largest element on top, so I
changed all comparisons so they did the right thing.
Some usage of PrioHeap was simply changed to a std::vector, using sort
at the right time, other usage had me just use the various heap functions
in the stl.
Diffstat (limited to 'src/mem/ruby/buffers/MessageBuffer.hh')
-rw-r--r-- | src/mem/ruby/buffers/MessageBuffer.hh | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh index 12799c871..9315eaec0 100644 --- a/src/mem/ruby/buffers/MessageBuffer.hh +++ b/src/mem/ruby/buffers/MessageBuffer.hh @@ -34,10 +34,12 @@ #ifndef __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ #define __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ +#include <algorithm> +#include <functional> #include <iostream> +#include <vector> #include <string> -#include "mem/gems_common/PrioHeap.hh" #include "mem/ruby/buffers/MessageBufferNode.hh" #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Global.hh" @@ -61,13 +63,16 @@ class MessageBuffer isReady() const { return ((m_prio_heap.size() > 0) && - (m_prio_heap.peekMin().m_time <= g_eventQueue_ptr->getTime())); + (m_prio_heap.front().m_time <= g_eventQueue_ptr->getTime())); } void delayHead() { - MessageBufferNode node = m_prio_heap.extractMin(); + MessageBufferNode node = m_prio_heap.front(); + std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(), + std::greater<MessageBufferNode>()); + m_prio_heap.pop_back(); enqueue(node.m_msgptr, 1); } @@ -93,13 +98,13 @@ class MessageBuffer peekMsgPtr() const { assert(isReady()); - return m_prio_heap.peekMin().m_msgptr; + return m_prio_heap.front().m_msgptr; } const MsgPtr& peekMsgPtrEvenIfNotReady() const { - return m_prio_heap.peekMin().m_msgptr; + return m_prio_heap.front().m_msgptr; } void enqueue(MsgPtr message) { enqueue(message, 1); } @@ -144,7 +149,7 @@ class MessageBuffer // Data Members (m_ prefix) Consumer* m_consumer_ptr; // Consumer to signal a wakeup(), can be NULL - PrioHeap<MessageBufferNode> m_prio_heap; + std::vector<MessageBufferNode> m_prio_heap; std::string m_name; int m_max_size; |