MessageBuffer.hh (10301:44839e8febbd) MessageBuffer.hh (10893:f567e80c0714)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 29 unchanged lines hidden (view full) ---

38#include <cassert>
39#include <functional>
40#include <iostream>
41#include <string>
42#include <vector>
43
44#include "mem/ruby/common/Address.hh"
45#include "mem/ruby/common/Consumer.hh"
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 29 unchanged lines hidden (view full) ---

38#include <cassert>
39#include <functional>
40#include <iostream>
41#include <string>
42#include <vector>
43
44#include "mem/ruby/common/Address.hh"
45#include "mem/ruby/common/Consumer.hh"
46#include "mem/ruby/network/MessageBufferNode.hh"
47#include "mem/ruby/slicc_interface/Message.hh"
48#include "mem/packet.hh"
49
50class MessageBuffer
51{
52 public:
53 MessageBuffer(const std::string &name = "");
54

--- 7 unchanged lines hidden (view full) ---

62 void stallMessage(const Address& addr);
63
64 // TRUE if head of queue timestamp <= SystemTime
65 bool isReady() const;
66
67 void
68 delayHead()
69 {
46#include "mem/ruby/slicc_interface/Message.hh"
47#include "mem/packet.hh"
48
49class MessageBuffer
50{
51 public:
52 MessageBuffer(const std::string &name = "");
53

--- 7 unchanged lines hidden (view full) ---

61 void stallMessage(const Address& addr);
62
63 // TRUE if head of queue timestamp <= SystemTime
64 bool isReady() const;
65
66 void
67 delayHead()
68 {
70 MessageBufferNode node = m_prio_heap.front();
69 MsgPtr m = m_prio_heap.front();
71 std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
70 std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
72 std::greater<MessageBufferNode>());
71 std::greater<MsgPtr>());
73 m_prio_heap.pop_back();
72 m_prio_heap.pop_back();
74 enqueue(node.m_msgptr, Cycles(1));
73 enqueue(m, Cycles(1));
75 }
76
77 bool areNSlotsAvailable(unsigned int n);
78 int getPriority() { return m_priority_rank; }
79 void setPriority(int rank) { m_priority_rank = rank; }
80 void setConsumer(Consumer* consumer)
81 {
82 if (m_consumer != NULL) {

--- 24 unchanged lines hidden (view full) ---

107 //! Function for extracting the message at the head of the
108 //! message queue. The function assumes that the queue is nonempty.
109 const Message* peek() const;
110
111 const MsgPtr&
112 peekMsgPtr() const
113 {
114 assert(isReady());
74 }
75
76 bool areNSlotsAvailable(unsigned int n);
77 int getPriority() { return m_priority_rank; }
78 void setPriority(int rank) { m_priority_rank = rank; }
79 void setConsumer(Consumer* consumer)
80 {
81 if (m_consumer != NULL) {

--- 24 unchanged lines hidden (view full) ---

106 //! Function for extracting the message at the head of the
107 //! message queue. The function assumes that the queue is nonempty.
108 const Message* peek() const;
109
110 const MsgPtr&
111 peekMsgPtr() const
112 {
113 assert(isReady());
115 return m_prio_heap.front().m_msgptr;
114 return m_prio_heap.front();
116 }
117
118 void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); }
119 void enqueue(MsgPtr message, Cycles delta);
120
121 //! Updates the delay cycles of the message at the head of the queue,
122 //! removes it from the queue and returns its total delay.
123 Cycles dequeue();

--- 39 unchanged lines hidden (view full) ---

163
164 // Data Members (m_ prefix)
165 //! The two ends of the buffer.
166 ClockedObject* m_sender;
167 ClockedObject* m_receiver;
168
169 //! Consumer to signal a wakeup(), can be NULL
170 Consumer* m_consumer;
115 }
116
117 void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); }
118 void enqueue(MsgPtr message, Cycles delta);
119
120 //! Updates the delay cycles of the message at the head of the queue,
121 //! removes it from the queue and returns its total delay.
122 Cycles dequeue();

--- 39 unchanged lines hidden (view full) ---

162
163 // Data Members (m_ prefix)
164 //! The two ends of the buffer.
165 ClockedObject* m_sender;
166 ClockedObject* m_receiver;
167
168 //! Consumer to signal a wakeup(), can be NULL
169 Consumer* m_consumer;
171 std::vector<MessageBufferNode> m_prio_heap;
170 std::vector<MsgPtr> m_prio_heap;
172
173 // use a std::map for the stalled messages as this container is
174 // sorted and ensures a well-defined iteration order
175 typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
176
177 StallMsgMapType m_stall_msg_map;
178 std::string m_name;
179

--- 36 unchanged lines hidden ---
171
172 // use a std::map for the stalled messages as this container is
173 // sorted and ensures a well-defined iteration order
174 typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
175
176 StallMsgMapType m_stall_msg_map;
177 std::string m_name;
178

--- 36 unchanged lines hidden ---