From: Nathan Binkert Date: Tue, 23 Mar 2010 01:43:53 +0000 (-0700) Subject: ruby: style pass X-Git-Tag: stable_2012_02_02~1440^2~1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ab13e2deb8f904ef2a233749193fa09ea7013c4;p=gem5.git ruby: style pass --- diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc index d157e2a94..83bb34dad 100644 --- a/src/mem/ruby/buffers/MessageBuffer.cc +++ b/src/mem/ruby/buffers/MessageBuffer.cc @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -27,318 +26,341 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * $Id$ - */ - #include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/system/System.hh" MessageBuffer::MessageBuffer(const string &name) { - m_msg_counter = 0; - m_consumer_ptr = NULL; - m_ordering_set = false; - m_strict_fifo = true; - m_size = 0; - m_max_size = -1; - m_last_arrival_time = 0; - m_randomization = true; - m_size_last_time_size_checked = 0; - m_time_last_time_size_checked = 0; - m_time_last_time_enqueue = 0; - m_time_last_time_pop = 0; - m_size_at_cycle_start = 0; - m_msgs_this_cycle = 0; - m_not_avail_count = 0; - m_priority_rank = 0; - m_name = name; + m_msg_counter = 0; + m_consumer_ptr = NULL; + m_ordering_set = false; + m_strict_fifo = true; + m_size = 0; + m_max_size = -1; + m_last_arrival_time = 0; + m_randomization = true; + m_size_last_time_size_checked = 0; + m_time_last_time_size_checked = 0; + m_time_last_time_enqueue = 0; + m_time_last_time_pop = 0; + m_size_at_cycle_start = 0; + m_msgs_this_cycle = 0; + m_not_avail_count = 0; + m_priority_rank = 0; + m_name = name; } -int MessageBuffer::getSize() +int +MessageBuffer::getSize() { - if(m_time_last_time_size_checked == g_eventQueue_ptr->getTime()){ - return m_size_last_time_size_checked; - } else { - m_time_last_time_size_checked = g_eventQueue_ptr->getTime(); - m_size_last_time_size_checked = m_size; - return m_size; - } + if (m_time_last_time_size_checked == g_eventQueue_ptr->getTime()) { + return m_size_last_time_size_checked; + } else { + m_time_last_time_size_checked = g_eventQueue_ptr->getTime(); + m_size_last_time_size_checked = m_size; + return m_size; + } } -bool MessageBuffer::areNSlotsAvailable(int n) +bool +MessageBuffer::areNSlotsAvailable(int n) { - // fast path when message buffers have infinite size - if(m_max_size == -1) { - return true; - } - - // determine my correct size for the current cycle - // pop operations shouldn't effect the network's visible size until next cycle, - // but enqueue operations effect the visible size immediately - int current_size = max(m_size_at_cycle_start, m_size); - if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { // no pops this cycle - m_size is correct - current_size = m_size; - } else { - if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { // no enqueues this cycle - m_size_at_cycle_start is correct - current_size = m_size_at_cycle_start; - } else { // both pops and enqueues occured this cycle - add new enqueued msgs to m_size_at_cycle_start - current_size = m_size_at_cycle_start+m_msgs_this_cycle; + // fast path when message buffers have infinite size + if (m_max_size == -1) { + return true; + } + + // determine my correct size for the current cycle + // pop operations shouldn't effect the network's visible size + // until next cycle, but enqueue operations effect the visible + // size immediately + int current_size = max(m_size_at_cycle_start, m_size); + if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { + // no pops this cycle - m_size is correct + current_size = m_size; + } else { + if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { + // no enqueues this cycle - m_size_at_cycle_start is correct + current_size = m_size_at_cycle_start; + } else { + // both pops and enqueues occured this cycle - add new + // enqueued msgs to m_size_at_cycle_start + current_size = m_size_at_cycle_start+m_msgs_this_cycle; + } + } + + // now compare the new size with our max size + if (current_size + n <= m_max_size) { + return true; + } else { + DEBUG_MSG(QUEUE_COMP, MedPrio, n); + DEBUG_MSG(QUEUE_COMP, MedPrio, current_size); + DEBUG_MSG(QUEUE_COMP, MedPrio, m_size); + DEBUG_MSG(QUEUE_COMP, MedPrio, m_max_size); + m_not_avail_count++; + return false; } - } - - // now compare the new size with our max size - if(current_size+n <= m_max_size){ - return true; - } else { - DEBUG_MSG(QUEUE_COMP,MedPrio,n); - DEBUG_MSG(QUEUE_COMP,MedPrio,current_size); - DEBUG_MSG(QUEUE_COMP,MedPrio,m_size); - DEBUG_MSG(QUEUE_COMP,MedPrio,m_max_size); - m_not_avail_count++; - return false; - } } -const MsgPtr MessageBuffer::getMsgPtrCopy() const +const MsgPtr +MessageBuffer::getMsgPtrCopy() const { - assert(isReady()); + assert(isReady()); - MsgPtr temp_msg; - temp_msg = *(m_prio_heap.peekMin().m_msgptr.ref()); - assert(temp_msg.ref() != NULL); - return temp_msg; + MsgPtr temp_msg; + temp_msg = *(m_prio_heap.peekMin().m_msgptr.ref()); + assert(temp_msg.ref() != NULL); + return temp_msg; } -const Message* MessageBuffer::peekAtHeadOfQueue() const +const Message* +MessageBuffer::peekAtHeadOfQueue() const { - const Message* msg_ptr; - DEBUG_NEWLINE(QUEUE_COMP,MedPrio); + const Message* msg_ptr; + DEBUG_NEWLINE(QUEUE_COMP, MedPrio); - DEBUG_MSG(QUEUE_COMP,MedPrio,"Peeking at head of queue " + m_name + " time: " - + int_to_string(g_eventQueue_ptr->getTime()) + "."); - assert(isReady()); + DEBUG_MSG(QUEUE_COMP, MedPrio, + "Peeking at head of queue " + m_name + " time: " + + int_to_string(g_eventQueue_ptr->getTime()) + "."); + assert(isReady()); - msg_ptr = m_prio_heap.peekMin().m_msgptr.ref(); - assert(msg_ptr != NULL); + msg_ptr = m_prio_heap.peekMin().m_msgptr.ref(); + assert(msg_ptr != NULL); - DEBUG_EXPR(QUEUE_COMP,MedPrio,*msg_ptr); - DEBUG_NEWLINE(QUEUE_COMP,MedPrio); - return msg_ptr; + DEBUG_EXPR(QUEUE_COMP, MedPrio, *msg_ptr); + DEBUG_NEWLINE(QUEUE_COMP, MedPrio); + return msg_ptr; } // FIXME - move me somewhere else -int random_time() +int +random_time() { - int time = 1; - time += random() & 0x3; // [0...3] - if ((random() & 0x7) == 0) { // 1 in 8 chance - time += 100 + (random() % 0xf); // 100 + [1...15] - } - return time; + int time = 1; + time += random() & 0x3; // [0...3] + if ((random() & 0x7) == 0) { // 1 in 8 chance + time += 100 + (random() % 0xf); // 100 + [1...15] + } + return time; } -void MessageBuffer::enqueue(const MsgPtr& message, Time delta) +void +MessageBuffer::enqueue(const MsgPtr& message, Time delta) { - DEBUG_NEWLINE(QUEUE_COMP,HighPrio); - DEBUG_MSG(QUEUE_COMP,HighPrio,"enqueue " + m_name + " time: " - + int_to_string(g_eventQueue_ptr->getTime()) + "."); - DEBUG_EXPR(QUEUE_COMP,MedPrio,message); - DEBUG_NEWLINE(QUEUE_COMP,HighPrio); - - m_msg_counter++; - m_size++; - - // record current time incase we have a pop that also adjusts my size - if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { - m_msgs_this_cycle = 0; // first msg this cycle - m_time_last_time_enqueue = g_eventQueue_ptr->getTime(); - } - m_msgs_this_cycle++; - - // ASSERT(m_max_size == -1 || m_size <= m_max_size + 1); - // the plus one is a kluge because of a SLICC issue - - if (!m_ordering_set) { - // WARN_EXPR(*this); - WARN_EXPR(m_name); - ERROR_MSG("Ordering property of this queue has not been set"); - } - - // Calculate the arrival time of the message, that is, the first - // cycle the message can be dequeued. -// printf ("delta %i \n", delta); - assert(delta>0); - Time current_time = g_eventQueue_ptr->getTime(); - Time arrival_time = 0; - if (!RubySystem::getRandomization() || (m_randomization == false)) { - // No randomization - arrival_time = current_time + delta; - - } else { - // Randomization - ignore delta - if (m_strict_fifo) { - if (m_last_arrival_time < current_time) { - m_last_arrival_time = current_time; - } - arrival_time = m_last_arrival_time + random_time(); - } else { - arrival_time = current_time + random_time(); + DEBUG_NEWLINE(QUEUE_COMP, HighPrio); + DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name + " time: " + + int_to_string(g_eventQueue_ptr->getTime()) + "."); + DEBUG_EXPR(QUEUE_COMP, MedPrio, message); + DEBUG_NEWLINE(QUEUE_COMP, HighPrio); + + m_msg_counter++; + m_size++; + + // record current time incase we have a pop that also adjusts my size + if (m_time_last_time_enqueue < g_eventQueue_ptr->getTime()) { + m_msgs_this_cycle = 0; // first msg this cycle + m_time_last_time_enqueue = g_eventQueue_ptr->getTime(); } - } + m_msgs_this_cycle++; + + // ASSERT(m_max_size == -1 || m_size <= m_max_size + 1); + // the plus one is a kluge because of a SLICC issue - // Check the arrival time - assert(arrival_time > current_time); - if (m_strict_fifo) { - if (arrival_time >= m_last_arrival_time) { + if (!m_ordering_set) { + // WARN_EXPR(*this); + WARN_EXPR(m_name); + ERROR_MSG("Ordering property of this queue has not been set"); + } + // Calculate the arrival time of the message, that is, the first + // cycle the message can be dequeued. + //printf ("delta %i \n", delta); + assert(delta>0); + Time current_time = g_eventQueue_ptr->getTime(); + Time arrival_time = 0; + if (!RubySystem::getRandomization() || (m_randomization == false)) { + // No randomization + arrival_time = current_time + delta; + } else { + // Randomization - ignore delta + if (m_strict_fifo) { + if (m_last_arrival_time < current_time) { + m_last_arrival_time = current_time; + } + arrival_time = m_last_arrival_time + random_time(); + } else { + arrival_time = current_time + random_time(); + } + } + + // Check the arrival time + assert(arrival_time > current_time); + if (m_strict_fifo) { + if (arrival_time < m_last_arrival_time) { + WARN_EXPR(*this); + WARN_EXPR(m_name); + WARN_EXPR(current_time); + WARN_EXPR(delta); + WARN_EXPR(arrival_time); + WARN_EXPR(m_last_arrival_time); + ERROR_MSG("FIFO ordering violated"); + } + } + m_last_arrival_time = arrival_time; + + // compute the delay cycles and set enqueue time + Message* msg_ptr = message.mod_ref(); + assert(msg_ptr != NULL); + + assert(g_eventQueue_ptr->getTime() >= msg_ptr->getLastEnqueueTime() && + "ensure we aren't dequeued early"); + + msg_ptr->setDelayedCycles(g_eventQueue_ptr->getTime() - + msg_ptr->getLastEnqueueTime() + + msg_ptr->getDelayedCycles()); + msg_ptr->setLastEnqueueTime(arrival_time); + + // Insert the message into the priority heap + MessageBufferNode thisNode(arrival_time, m_msg_counter, message); + m_prio_heap.insert(thisNode); + + DEBUG_NEWLINE(QUEUE_COMP, HighPrio); + DEBUG_MSG(QUEUE_COMP, HighPrio, "enqueue " + m_name + + " with arrival_time " + int_to_string(arrival_time) + + " cur_time: " + int_to_string(g_eventQueue_ptr->getTime()) + + "."); + DEBUG_EXPR(QUEUE_COMP, MedPrio, message); + DEBUG_NEWLINE(QUEUE_COMP, HighPrio); + + // Schedule the wakeup + if (m_consumer_ptr != NULL) { + g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, arrival_time); } else { - WARN_EXPR(*this); - WARN_EXPR(m_name); - WARN_EXPR(current_time); - WARN_EXPR(delta); - WARN_EXPR(arrival_time); - WARN_EXPR(m_last_arrival_time); - ERROR_MSG("FIFO ordering violated"); + WARN_EXPR(*this); + WARN_EXPR(m_name); + ERROR_MSG("No consumer"); } - } - m_last_arrival_time = arrival_time; - - // compute the delay cycles and set enqueue time - Message* msg_ptr = NULL; - msg_ptr = message.mod_ref(); - assert(msg_ptr != NULL); - assert(g_eventQueue_ptr->getTime() >= msg_ptr->getLastEnqueueTime()); // ensure we aren't dequeued early - msg_ptr->setDelayedCycles((g_eventQueue_ptr->getTime() - msg_ptr->getLastEnqueueTime())+msg_ptr->getDelayedCycles()); - msg_ptr->setLastEnqueueTime(arrival_time); - - // Insert the message into the priority heap - MessageBufferNode thisNode(arrival_time, m_msg_counter, message); - m_prio_heap.insert(thisNode); - - DEBUG_NEWLINE(QUEUE_COMP,HighPrio); - DEBUG_MSG(QUEUE_COMP,HighPrio,"enqueue " + m_name - + " with arrival_time " + int_to_string(arrival_time) - + " cur_time: " + int_to_string(g_eventQueue_ptr->getTime()) + "."); - DEBUG_EXPR(QUEUE_COMP,MedPrio,message); - DEBUG_NEWLINE(QUEUE_COMP,HighPrio); - - // Schedule the wakeup - if (m_consumer_ptr != NULL) { - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, arrival_time); - } else { - WARN_EXPR(*this); - WARN_EXPR(m_name); - ERROR_MSG("No consumer"); - } } -int MessageBuffer::dequeue_getDelayCycles(MsgPtr& message) +int +MessageBuffer::dequeue_getDelayCycles(MsgPtr& message) { - int delay_cycles = -1; // null value + int delay_cycles = -1; // null value - dequeue(message); + dequeue(message); - // get the delay cycles - delay_cycles = setAndReturnDelayCycles(message); + // get the delay cycles + delay_cycles = setAndReturnDelayCycles(message); - assert(delay_cycles >= 0); - return delay_cycles; + assert(delay_cycles >= 0); + return delay_cycles; } -void MessageBuffer::dequeue(MsgPtr& message) +void +MessageBuffer::dequeue(MsgPtr& message) { - DEBUG_MSG(QUEUE_COMP,MedPrio,"dequeue from " + m_name); - message = m_prio_heap.peekMin().m_msgptr; + DEBUG_MSG(QUEUE_COMP, MedPrio, "dequeue from " + m_name); + message = m_prio_heap.peekMin().m_msgptr; - pop(); - DEBUG_EXPR(QUEUE_COMP,MedPrio,message); + pop(); + DEBUG_EXPR(QUEUE_COMP, MedPrio, message); } -int MessageBuffer::dequeue_getDelayCycles() +int +MessageBuffer::dequeue_getDelayCycles() { - int delay_cycles = -1; // null value + int delay_cycles = -1; // null value - // get MsgPtr of the message about to be dequeued - MsgPtr message = m_prio_heap.peekMin().m_msgptr; + // get MsgPtr of the message about to be dequeued + MsgPtr message = m_prio_heap.peekMin().m_msgptr; - // get the delay cycles - delay_cycles = setAndReturnDelayCycles(message); + // get the delay cycles + delay_cycles = setAndReturnDelayCycles(message); - dequeue(); + dequeue(); - assert(delay_cycles >= 0); - return delay_cycles; + assert(delay_cycles >= 0); + return delay_cycles; } -void MessageBuffer::pop() +void +MessageBuffer::pop() { - DEBUG_MSG(QUEUE_COMP,MedPrio,"pop from " + m_name); - assert(isReady()); - m_prio_heap.extractMin(); - // record previous size and time so the current buffer size isn't adjusted until next cycle - if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { - m_size_at_cycle_start = m_size; - m_time_last_time_pop = g_eventQueue_ptr->getTime(); - } - m_size--; + DEBUG_MSG(QUEUE_COMP, MedPrio, "pop from " + m_name); + assert(isReady()); + m_prio_heap.extractMin(); + // record previous size and time so the current buffer size isn't + // adjusted until next cycle + if (m_time_last_time_pop < g_eventQueue_ptr->getTime()) { + m_size_at_cycle_start = m_size; + m_time_last_time_pop = g_eventQueue_ptr->getTime(); + } + m_size--; } -void MessageBuffer::clear() +void +MessageBuffer::clear() { - while(m_prio_heap.size() > 0){ - m_prio_heap.extractMin(); - } + while(m_prio_heap.size() > 0){ + m_prio_heap.extractMin(); + } - ASSERT(m_prio_heap.size() == 0); + ASSERT(m_prio_heap.size() == 0); - m_msg_counter = 0; - m_size = 0; - m_time_last_time_enqueue = 0; - m_time_last_time_pop = 0; - m_size_at_cycle_start = 0; - m_msgs_this_cycle = 0; + m_msg_counter = 0; + m_size = 0; + m_time_last_time_enqueue = 0; + m_time_last_time_pop = 0; + m_size_at_cycle_start = 0; + m_msgs_this_cycle = 0; } -void MessageBuffer::recycle() +void +MessageBuffer::recycle() { - DEBUG_MSG(QUEUE_COMP,MedPrio,"recycling " + m_name); - assert(isReady()); - MessageBufferNode node = m_prio_heap.extractMin(); - node.m_time = g_eventQueue_ptr->getTime() + m_recycle_latency; - m_prio_heap.insert(node); - g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, g_eventQueue_ptr->getTime() + m_recycle_latency); + DEBUG_MSG(QUEUE_COMP, MedPrio, "recycling " + m_name); + assert(isReady()); + MessageBufferNode node = m_prio_heap.extractMin(); + node.m_time = g_eventQueue_ptr->getTime() + m_recycle_latency; + m_prio_heap.insert(node); + g_eventQueue_ptr->scheduleEventAbsolute(m_consumer_ptr, + g_eventQueue_ptr->getTime() + m_recycle_latency); } -int MessageBuffer::setAndReturnDelayCycles(MsgPtr& message) +int +MessageBuffer::setAndReturnDelayCycles(MsgPtr& message) { - int delay_cycles = -1; // null value + int delay_cycles = -1; // null value - // get the delay cycles of the message at the top of the queue - Message* msg_ptr = message.ref(); + // get the delay cycles of the message at the top of the queue + Message* msg_ptr = message.ref(); - // this function should only be called on dequeue - // ensure the msg hasn't been enqueued - assert(msg_ptr->getLastEnqueueTime() <= g_eventQueue_ptr->getTime()); - msg_ptr->setDelayedCycles((g_eventQueue_ptr->getTime() - msg_ptr->getLastEnqueueTime())+msg_ptr->getDelayedCycles()); - delay_cycles = msg_ptr->getDelayedCycles(); + // this function should only be called on dequeue + // ensure the msg hasn't been enqueued + assert(msg_ptr->getLastEnqueueTime() <= g_eventQueue_ptr->getTime()); + msg_ptr->setDelayedCycles(g_eventQueue_ptr->getTime() - + msg_ptr->getLastEnqueueTime() + + msg_ptr->getDelayedCycles()); + delay_cycles = msg_ptr->getDelayedCycles(); - assert(delay_cycles >= 0); - return delay_cycles; + assert(delay_cycles >= 0); + return delay_cycles; } -void MessageBuffer::print(ostream& out) const +void +MessageBuffer::print(ostream& out) const { - out << "[MessageBuffer: "; - if (m_consumer_ptr != NULL) { - out << " consumer-yes "; - } - out << m_prio_heap << "] " << m_name << endl; + out << "[MessageBuffer: "; + if (m_consumer_ptr != NULL) { + out << " consumer-yes "; + } + out << m_prio_heap << "] " << m_name << endl; } -void MessageBuffer::printStats(ostream& out) +void +MessageBuffer::printStats(ostream& out) { - out << "MessageBuffer: " << m_name << " stats - msgs:" << m_msg_counter << " full:" << m_not_avail_count << endl; + out << "MessageBuffer: " << m_name << " stats - msgs:" << m_msg_counter + << " full:" << m_not_avail_count << endl; } - diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh index 8d5a8de25..8fc86af97 100644 --- a/src/mem/ruby/buffers/MessageBuffer.hh +++ b/src/mem/ruby/buffers/MessageBuffer.hh @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -28,137 +27,156 @@ */ /* - * $Id$ - * - * Description: Unordered buffer of messages that can be inserted such + * Unordered buffer of messages that can be inserted such * that they can be dequeued after a given delta time has expired. - * */ -#ifndef MESSAGEBUFFER_H -#define MESSAGEBUFFER_H +#ifndef __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ +#define __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ #include #include -#include "mem/ruby/common/Global.hh" +#include "mem/gems_common/PrioHeap.hh" +#include "mem/gems_common/util.hh" #include "mem/ruby/buffers/MessageBufferNode.hh" #include "mem/ruby/common/Consumer.hh" +#include "mem/ruby/common/Global.hh" #include "mem/ruby/eventqueue/RubyEventQueue.hh" #include "mem/ruby/slicc_interface/Message.hh" -#include "mem/gems_common/PrioHeap.hh" -#include "mem/gems_common/util.hh" -class MessageBuffer { -public: - // Constructors - MessageBuffer(const std::string &name = ""); - - // ~MessageBuffer() - - // Public Methods - - static void printConfig(std::ostream& out) {} - void setRecycleLatency(int recycle_latency) { m_recycle_latency = recycle_latency; } - - // TRUE if head of queue timestamp <= SystemTime - bool isReady() const { - return ((m_prio_heap.size() > 0) && - (m_prio_heap.peekMin().m_time <= g_eventQueue_ptr->getTime())); - } - - void delayHead() { - MessageBufferNode node = m_prio_heap.extractMin(); - enqueue(node.m_msgptr, 1); - } - - bool areNSlotsAvailable(int n); - int getPriority() { return m_priority_rank; } - void setPriority(int rank) { m_priority_rank = rank; } - void setConsumer(Consumer* consumer_ptr) { ASSERT(m_consumer_ptr==NULL); m_consumer_ptr = consumer_ptr; } - void setDescription(const std::string& name) { m_name = name; } - std::string getDescription() { return m_name;} - - Consumer* getConsumer() { return m_consumer_ptr; } - - const Message* peekAtHeadOfQueue() const; - const Message* peek() const { return peekAtHeadOfQueue(); } - const MsgPtr getMsgPtrCopy() const; - const MsgPtr& peekMsgPtr() const { assert(isReady()); return m_prio_heap.peekMin().m_msgptr; } - const MsgPtr& peekMsgPtrEvenIfNotReady() const {return m_prio_heap.peekMin().m_msgptr; } - - void enqueue(const MsgPtr& message) { enqueue(message, 1); } - void enqueue(const MsgPtr& message, Time delta); - // void enqueueAbsolute(const MsgPtr& message, Time absolute_time); - int dequeue_getDelayCycles(MsgPtr& message); // returns delay cycles of the message - void dequeue(MsgPtr& message); - int dequeue_getDelayCycles(); // returns delay cycles of the message - void dequeue() { pop(); } - void pop(); - void recycle(); - bool isEmpty() const { return m_prio_heap.size() == 0; } - - void setOrdering(bool order) { m_strict_fifo = order; m_ordering_set = true; } - void setSize(int size) {m_max_size = size;} - int getSize(); - void setRandomization(bool random_flag) { m_randomization = random_flag; } - - void clear(); - - void print(std::ostream& out) const; - void printStats(std::ostream& out); - void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; } - -private: - //added by SS - int m_recycle_latency; - - // Private Methods - int setAndReturnDelayCycles(MsgPtr& message); - - // Private copy constructor and assignment operator - MessageBuffer(const MessageBuffer& obj); - MessageBuffer& operator=(const MessageBuffer& obj); - - // Data Members (m_ prefix) - Consumer* m_consumer_ptr; // Consumer to signal a wakeup(), can be NULL - PrioHeap m_prio_heap; - std::string m_name; - - int m_max_size; - int m_size; - - Time m_time_last_time_size_checked; - int m_size_last_time_size_checked; - - // variables used so enqueues appear to happen imediately, while pop happen the next cycle - Time m_time_last_time_enqueue; - Time m_time_last_time_pop; - int m_size_at_cycle_start; - int m_msgs_this_cycle; - - int m_not_avail_count; // count the # of times I didn't have N slots available - int m_msg_counter; - int m_priority_rank; - bool m_strict_fifo; - bool m_ordering_set; - bool m_randomization; - Time m_last_arrival_time; +class MessageBuffer +{ + public: + MessageBuffer(const std::string &name = ""); + + static void printConfig(std::ostream& out) {} + void + setRecycleLatency(int recycle_latency) + { + m_recycle_latency = recycle_latency; + } + + // TRUE if head of queue timestamp <= SystemTime + bool + isReady() const + { + return ((m_prio_heap.size() > 0) && + (m_prio_heap.peekMin().m_time <= g_eventQueue_ptr->getTime())); + } + + void + delayHead() + { + MessageBufferNode node = m_prio_heap.extractMin(); + enqueue(node.m_msgptr, 1); + } + + bool areNSlotsAvailable(int n); + int getPriority() { return m_priority_rank; } + void setPriority(int rank) { m_priority_rank = rank; } + void setConsumer(Consumer* consumer_ptr) + { + ASSERT(m_consumer_ptr == NULL); + m_consumer_ptr = consumer_ptr; + } + + void setDescription(const std::string& name) { m_name = name; } + std::string getDescription() { return m_name;} + + Consumer* getConsumer() { return m_consumer_ptr; } + + const Message* peekAtHeadOfQueue() const; + const Message* peek() const { return peekAtHeadOfQueue(); } + const MsgPtr getMsgPtrCopy() const; + + const MsgPtr& + peekMsgPtr() const + { + assert(isReady()); + return m_prio_heap.peekMin().m_msgptr; + } + + const MsgPtr& + peekMsgPtrEvenIfNotReady() const + { + return m_prio_heap.peekMin().m_msgptr; + } + + void enqueue(const MsgPtr& message) { enqueue(message, 1); } + void enqueue(const MsgPtr& message, Time delta); + // void enqueueAbsolute(const MsgPtr& message, Time absolute_time); + int dequeue_getDelayCycles(MsgPtr& message); // returns delay + // cycles of the + // message + void dequeue(MsgPtr& message); + int dequeue_getDelayCycles(); // returns delay cycles of the message + void dequeue() { pop(); } + void pop(); + void recycle(); + bool isEmpty() const { return m_prio_heap.size() == 0; } + + void + setOrdering(bool order) + { + m_strict_fifo = order; + m_ordering_set = true; + } + void setSize(int size) { m_max_size = size; } + int getSize(); + void setRandomization(bool random_flag) { m_randomization = random_flag; } + + void clear(); + + void print(std::ostream& out) const; + void printStats(std::ostream& out); + void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; } + + private: + //added by SS + int m_recycle_latency; + + // Private Methods + int setAndReturnDelayCycles(MsgPtr& message); + + // Private copy constructor and assignment operator + MessageBuffer(const MessageBuffer& obj); + MessageBuffer& operator=(const MessageBuffer& obj); + + // Data Members (m_ prefix) + Consumer* m_consumer_ptr; // Consumer to signal a wakeup(), can be NULL + PrioHeap m_prio_heap; + std::string m_name; + + int m_max_size; + int m_size; + + Time m_time_last_time_size_checked; + int m_size_last_time_size_checked; + + // variables used so enqueues appear to happen imediately, while + // pop happen the next cycle + Time m_time_last_time_enqueue; + Time m_time_last_time_pop; + int m_size_at_cycle_start; + int m_msgs_this_cycle; + + int m_not_avail_count; // count the # of times I didn't have N + // slots available + int m_msg_counter; + int m_priority_rank; + bool m_strict_fifo; + bool m_ordering_set; + bool m_randomization; + Time m_last_arrival_time; }; -// Output operator declaration -//template -std::ostream& operator<<(std::ostream& out, const MessageBuffer& obj); - -// ******************* Definitions ******************* - -// Output operator definition -extern inline -std::ostream& operator<<(std::ostream& out, const MessageBuffer& obj) +inline std::ostream& +operator<<(std::ostream& out, const MessageBuffer& obj) { - obj.print(out); - out << std::flush; - return out; + obj.print(out); + out << std::flush; + return out; } -#endif //MESSAGEBUFFER_H +#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ diff --git a/src/mem/ruby/buffers/MessageBufferNode.cc b/src/mem/ruby/buffers/MessageBufferNode.cc index aec977acd..698eeab25 100644 --- a/src/mem/ruby/buffers/MessageBufferNode.cc +++ b/src/mem/ruby/buffers/MessageBufferNode.cc @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -32,9 +31,9 @@ void MessageBufferNode::print(std::ostream& out) const { - out << "["; - out << m_time << ", "; - out << m_msg_counter << ", "; - out << m_msgptr << "; "; - out << "]"; + out << "["; + out << m_time << ", "; + out << m_msg_counter << ", "; + out << m_msgptr << "; "; + out << "]"; } diff --git a/src/mem/ruby/buffers/MessageBufferNode.hh b/src/mem/ruby/buffers/MessageBufferNode.hh index 747c1d889..9ead9b9aa 100644 --- a/src/mem/ruby/buffers/MessageBufferNode.hh +++ b/src/mem/ruby/buffers/MessageBufferNode.hh @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -27,64 +26,55 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MESSAGEBUFFERNODE_H -#define MESSAGEBUFFERNODE_H +#ifndef __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__ +#define __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__ #include #include "mem/ruby/common/Global.hh" #include "mem/ruby/slicc_interface/Message.hh" -class MessageBufferNode { -public: - // Constructors - MessageBufferNode() { m_time = 0; m_msg_counter = 0; } - MessageBufferNode(const Time& time, int counter, const MsgPtr& msgptr) - { m_time = time; m_msgptr = msgptr; m_msg_counter = counter; } - // Destructor - //~MessageBufferNode(); +class MessageBufferNode +{ + public: + MessageBufferNode() + { + m_time = 0; + m_msg_counter = 0; + } - // Public Methods - void print(std::ostream& out) const; -private: - // Private Methods + MessageBufferNode(const Time& time, int counter, const MsgPtr& msgptr) + { + m_time = time; + m_msgptr = msgptr; + m_msg_counter = counter; + } - // Default copy constructor and assignment operator - // MessageBufferNode(const MessageBufferNode& obj); - // MessageBufferNode& operator=(const MessageBufferNode& obj); + void print(std::ostream& out) const; - // Data Members (m_ prefix) -public: - Time m_time; - int m_msg_counter; // FIXME, should this be a 64-bit value? - MsgPtr m_msgptr; + public: + Time m_time; + int m_msg_counter; // FIXME, should this be a 64-bit value? + MsgPtr m_msgptr; }; -// Output operator declaration -std::ostream& operator<<(std::ostream& out, const MessageBufferNode& obj); - -// ******************* Definitions ******************* - -inline extern bool node_less_then_eq(const MessageBufferNode& n1, const MessageBufferNode& n2); - -inline extern -bool node_less_then_eq(const MessageBufferNode& n1, const MessageBufferNode& n2) +inline bool +node_less_then_eq(const MessageBufferNode& n1, const MessageBufferNode& n2) { - if (n1.m_time == n2.m_time) { - assert(n1.m_msg_counter != n2.m_msg_counter); - return (n1.m_msg_counter <= n2.m_msg_counter); - } else { - return (n1.m_time <= n2.m_time); - } + if (n1.m_time == n2.m_time) { + assert(n1.m_msg_counter != n2.m_msg_counter); + return (n1.m_msg_counter <= n2.m_msg_counter); + } else { + return (n1.m_time <= n2.m_time); + } } -// Output operator definition -extern inline -std::ostream& operator<<(std::ostream& out, const MessageBufferNode& obj) +inline std::ostream& +operator<<(std::ostream& out, const MessageBufferNode& obj) { - obj.print(out); - out << std::flush; - return out; + obj.print(out); + out << std::flush; + return out; } -#endif //MESSAGEBUFFERNODE_H +#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFERNODE_HH__ diff --git a/src/mem/ruby/common/Address.cc b/src/mem/ruby/common/Address.cc index b4ad39294..e74bdb47b 100644 --- a/src/mem/ruby/common/Address.cc +++ b/src/mem/ruby/common/Address.cc @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -27,42 +26,41 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * $Id$ - */ - #include "mem/ruby/common/Address.hh" -void Address::output(ostream& out) const +void +Address::output(ostream& out) const { - // Note: this outputs addresses in the form "ffff", not "0xffff". - // This code should always be able to write out addresses in a - // format that can be read in by the below input() method. Please - // don't change this without talking to Milo first. - out << hex << m_address << dec; + // Note: this outputs addresses in the form "ffff", not "0xffff". + // This code should always be able to write out addresses in a + // format that can be read in by the below input() method. Please + // don't change this without talking to Milo first. + out << hex << m_address << dec; } -void Address::input(istream& in) +void +Address::input(istream& in) { - // Note: this only works with addresses in the form "ffff", not - // "0xffff". This code should always be able to read in addresses - // written out by the above output() method. Please don't change - // this without talking to Milo first. - in >> hex >> m_address >> dec; + // Note: this only works with addresses in the form "ffff", not + // "0xffff". This code should always be able to read in addresses + // written out by the above output() method. Please don't change + // this without talking to Milo first. + in >> hex >> m_address >> dec; } Address::Address(const Address& obj) { - m_address = obj.m_address; + m_address = obj.m_address; } -Address& Address::operator=(const Address& obj) +Address& +Address::operator=(const Address& obj) { - if (this == &obj) { - // assert(false); - } else { - m_address = obj.m_address; - } - return *this; + if (this == &obj) { + // assert(false); + } else { + m_address = obj.m_address; + } + return *this; } diff --git a/src/mem/ruby/common/Address.hh b/src/mem/ruby/common/Address.hh index 7da5ed0fe..73327e617 100644 --- a/src/mem/ruby/common/Address.hh +++ b/src/mem/ruby/common/Address.hh @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999 Mark D. Hill and David A. Wood * All rights reserved. @@ -27,20 +26,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * $Id$ - */ - -#ifndef ADDRESS_H -#define ADDRESS_H +#ifndef __MEM_RUBY_COMMON_ADDRESS_HH__ +#define __MEM_RUBY_COMMON_ADDRESS_HH__ #include #include "base/hashmap.hh" #include "mem/ruby/common/Global.hh" -#include "mem/ruby/system/System.hh" -#include "mem/ruby/system/NodeID.hh" #include "mem/ruby/system/MachineID.hh" +#include "mem/ruby/system/NodeID.hh" +#include "mem/ruby/system/System.hh" const int ADDRESS_WIDTH = 64; // address width in bytes @@ -48,124 +43,131 @@ class Address; typedef Address PhysAddress; typedef Address VirtAddress; -class Address { -public: - // Constructors - Address() { m_address = 0; } - explicit Address(physical_address_t address) { m_address = address; } - - Address(const Address& obj); - Address& operator=(const Address& obj); - - // Destructor - // ~Address(); - - // Public Methods - - void setAddress(physical_address_t address) { m_address = address; } - physical_address_t getAddress() const {return m_address;} - // selects bits inclusive - physical_address_t bitSelect(int small, int big) const; - physical_address_t bitRemove(int small, int big) const; - physical_address_t maskLowOrderBits(int number) const; - physical_address_t maskHighOrderBits(int number) const; - physical_address_t shiftLowOrderBits(int number) const; - physical_address_t getLineAddress() const - { return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); } - physical_address_t getOffset() const - { return bitSelect(0, RubySystem::getBlockSizeBits()-1); } - - void makeLineAddress() { m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()); } - // returns the next stride address based on line address - void makeNextStrideAddress( int stride) { - m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()) - + RubySystem::getBlockSizeBytes()*stride; - } - int getBankSetNum() const; - int getBankSetDist() const; +class Address +{ + public: + Address() + : m_address(0) + { } + + explicit + Address(physical_address_t address) + : m_address(address) + { } + + Address(const Address& obj); + Address& operator=(const Address& obj); + + void setAddress(physical_address_t address) { m_address = address; } + physical_address_t getAddress() const {return m_address;} + // selects bits inclusive + physical_address_t bitSelect(int small, int big) const; + physical_address_t bitRemove(int small, int big) const; + physical_address_t maskLowOrderBits(int number) const; + physical_address_t maskHighOrderBits(int number) const; + physical_address_t shiftLowOrderBits(int number) const; + + physical_address_t + getLineAddress() const + { + return bitSelect(RubySystem::getBlockSizeBits(), ADDRESS_WIDTH); + } - Index memoryModuleIndex() const; + physical_address_t + getOffset() const + { + return bitSelect(0, RubySystem::getBlockSizeBits() - 1); + } - void print(ostream& out) const; - void output(ostream& out) const; - void input(istream& in); + void + makeLineAddress() + { + m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()); + } - void setOffset( int offset ){ - // first, zero out the offset bits - makeLineAddress(); - m_address |= (physical_address_t) offset; - } + // returns the next stride address based on line address + void + makeNextStrideAddress(int stride) + { + m_address = maskLowOrderBits(RubySystem::getBlockSizeBits()) + + RubySystem::getBlockSizeBytes()*stride; + } -private: - // Private Methods + int getBankSetNum() const; + int getBankSetDist() const; - // Private copy constructor and assignment operator - // Address(const Address& obj); - // Address& operator=(const Address& obj); + Index memoryModuleIndex() const; - // Data Members (m_ prefix) - physical_address_t m_address; -}; + void print(ostream& out) const; + void output(ostream& out) const; + void input(istream& in); -inline -Address line_address(const Address& addr) { Address temp(addr); temp.makeLineAddress(); return temp; } + void + setOffset(int offset) + { + // first, zero out the offset bits + makeLineAddress(); + m_address |= (physical_address_t) offset; + } -// Output operator declaration -ostream& operator<<(ostream& out, const Address& obj); -// comparison operator declaration -bool operator==(const Address& obj1, const Address& obj2); -bool operator!=(const Address& obj1, const Address& obj2); -bool operator<(const Address& obj1, const Address& obj2); -/* Address& operator=(const physical_address_t address); */ + private: + physical_address_t m_address; +}; -inline -bool operator<(const Address& obj1, const Address& obj2) +inline Address +line_address(const Address& addr) { - return obj1.getAddress() < obj2.getAddress(); + Address temp(addr); + temp.makeLineAddress(); + return temp; } -// ******************* Definitions ******************* +inline bool +operator<(const Address& obj1, const Address& obj2) +{ + return obj1.getAddress() < obj2.getAddress(); +} -// Output operator definition -inline -ostream& operator<<(ostream& out, const Address& obj) +inline ostream& +operator<<(ostream& out, const Address& obj) { - obj.print(out); - out << flush; - return out; + obj.print(out); + out << flush; + return out; } -inline -bool operator==(const Address& obj1, const Address& obj2) +inline bool +operator==(const Address& obj1, const Address& obj2) { - return (obj1.getAddress() == obj2.getAddress()); + return (obj1.getAddress() == obj2.getAddress()); } -inline -bool operator!=(const Address& obj1, const Address& obj2) +inline bool +operator!=(const Address& obj1, const Address& obj2) { - return (obj1.getAddress() != obj2.getAddress()); + return (obj1.getAddress() != obj2.getAddress()); } -inline -physical_address_t Address::bitSelect(int small, int big) const // rips bits inclusive +// rips bits inclusive +inline physical_address_t +Address::bitSelect(int small, int big) const { - physical_address_t mask; - assert((unsigned)big >= (unsigned)small); + physical_address_t mask; + assert((unsigned)big >= (unsigned)small); - if (big >= ADDRESS_WIDTH - 1) { - return (m_address >> small); - } else { - mask = ~((physical_address_t)~0 << (big + 1)); - // FIXME - this is slow to manipulate a 64-bit number using 32-bits - physical_address_t partial = (m_address & mask); - return (partial >> small); - } + if (big >= ADDRESS_WIDTH - 1) { + return (m_address >> small); + } else { + mask = ~((physical_address_t)~0 << (big + 1)); + // FIXME - this is slow to manipulate a 64-bit number using 32-bits + physical_address_t partial = (m_address & mask); + return (partial >> small); + } } // removes bits inclusive -inline -physical_address_t Address::bitRemove(int small, int big) const +inline physical_address_t +Address::bitRemove(int small, int big) const { physical_address_t mask; assert((unsigned)big >= (unsigned)small); @@ -184,60 +186,64 @@ physical_address_t Address::bitRemove(int small, int big) const mask = (physical_address_t)~0 << (big + 1); physical_address_t higher_bits = m_address & mask; - // // Shift the valid high bits over the removed section - // higher_bits = higher_bits >> (big - small); return (higher_bits | lower_bits); } } -inline -physical_address_t Address::maskLowOrderBits(int number) const +inline physical_address_t +Address::maskLowOrderBits(int number) const { physical_address_t mask; if (number >= ADDRESS_WIDTH - 1) { - mask = ~0; + mask = ~0; } else { - mask = (physical_address_t)~0 << number; + mask = (physical_address_t)~0 << number; } return (m_address & mask); } -inline -physical_address_t Address::maskHighOrderBits(int number) const +inline physical_address_t +Address::maskHighOrderBits(int number) const { - physical_address_t mask; + physical_address_t mask; - if (number >= ADDRESS_WIDTH - 1) { - mask = ~0; - } else { - mask = (physical_address_t)~0 >> number; - } - return (m_address & mask); + if (number >= ADDRESS_WIDTH - 1) { + mask = ~0; + } else { + mask = (physical_address_t)~0 >> number; + } + return (m_address & mask); } -inline -physical_address_t Address::shiftLowOrderBits(int number) const +inline physical_address_t +Address::shiftLowOrderBits(int number) const { - return (m_address >> number); + return (m_address >> number); } -inline -integer_t Address::memoryModuleIndex() const +inline integer_t +Address::memoryModuleIndex() const { - integer_t index = bitSelect(RubySystem::getBlockSizeBits()+RubySystem::getMemorySizeBits(), ADDRESS_WIDTH); - assert (index >= 0); - return index; - - // Index indexHighPortion = address.bitSelect(MEMORY_SIZE_BITS-1, PAGE_SIZE_BITS+NUMBER_OF_MEMORY_MODULE_BITS); - // Index indexLowPortion = address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS-1); - - //Index index = indexLowPortion | (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS)); - - /* - Round-robin mapping of addresses, at page size granularity + integer_t index = + bitSelect(RubySystem::getBlockSizeBits() + + RubySystem::getMemorySizeBits(), ADDRESS_WIDTH); + assert (index >= 0); + return index; + + // Index indexHighPortion = + // address.bitSelect(MEMORY_SIZE_BITS - 1, + // PAGE_SIZE_BITS + NUMBER_OF_MEMORY_MODULE_BITS); + // Index indexLowPortion = + // address.bitSelect(DATA_BLOCK_BITS, PAGE_SIZE_BITS - 1); + // + // Index index = indexLowPortion | + // (indexHighPortion << (PAGE_SIZE_BITS - DATA_BLOCK_BITS)); + + /* + Round-robin mapping of addresses, at page size granularity ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS | | | | @@ -249,29 +255,39 @@ ADDRESS_WIDTH MEMORY_SIZE_BITS PAGE_SIZE_BITS DATA_BLOCK_BITS indexHighPortion indexLowPortion <-------> NUMBER_OF_MEMORY_MODULE_BITS - */ + */ } -inline -void Address::print(ostream& out) const +inline void +Address::print(ostream& out) const { using namespace std; - out << "[" << hex << "0x" << m_address << "," << " line 0x" << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]" << flush; + out << "[" << hex << "0x" << m_address << "," << " line 0x" + << maskLowOrderBits(RubySystem::getBlockSizeBits()) << dec << "]" + << flush; } class Address; namespace __hash_namespace { - template <> struct hash
- { - size_t operator()(const Address &s) const { return (size_t) s.getAddress(); } - }; -} -namespace std { - template <> struct equal_to
- { - bool operator()(const Address& s1, const Address& s2) const { return s1 == s2; } - }; -} +template <> struct hash
+{ + size_t + operator()(const Address &s) const + { + return (size_t)s.getAddress(); + } +}; +/* namespace __hash_namespace */ } -#endif //ADDRESS_H +namespace std { +template <> struct equal_to
+{ + bool + operator()(const Address& s1, const Address& s2) const + { + return s1 == s2; + } +}; +/* namespace std */ } +#endif // __MEM_RUBY_COMMON_ADDRESS_HH__ diff --git a/src/mem/ruby/common/Consumer.hh b/src/mem/ruby/common/Consumer.hh index e541ef615..c1f8bc42e 100644 --- a/src/mem/ruby/common/Consumer.hh +++ b/src/mem/ruby/common/Consumer.hh @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -28,16 +27,13 @@ */ /* - * $Id$ - * - * Description: This is the virtual base class of all classes that can - * be the targets of wakeup events. There is only two methods, - * wakeup() and print() and no data members. - * + * This is the virtual base class of all classes that can be the + * targets of wakeup events. There is only two methods, wakeup() and + * print() and no data members. */ -#ifndef CONSUMER_H -#define CONSUMER_H +#ifndef __MEM_RUBY_COMMON_CONSUMER_HH__ +#define __MEM_RUBY_COMMON_CONSUMER_HH__ #include #include @@ -47,68 +43,74 @@ class MessageBuffer; -class Consumer { -public: - // Constructors - Consumer() { m_last_scheduled_wakeup = 0; m_last_wakeup = 0; } - - // Destructor - virtual ~Consumer() { } - - // Public Methods - pure virtual methods - void triggerWakeup(RubyEventQueue * eventQueue) - { - Time time = eventQueue->getTime(); - if (m_last_wakeup != time) { - wakeup(); m_last_wakeup = time; - } - } - virtual void wakeup() = 0; - virtual void print(std::ostream& out) const = 0; - const Time& getLastScheduledWakeup() const - { - return m_last_scheduled_wakeup; - } - void setLastScheduledWakeup(const Time& time) - { - m_last_scheduled_wakeup = time; - } - bool alreadyScheduled(Time time) - { - return (m_scheduled_wakeups.find(time) != m_scheduled_wakeups.end()); - } - void insertScheduledWakeupTime(Time time) - { - m_scheduled_wakeups.insert(time); - } - void removeScheduledWakeupTime(Time time) - { - assert(alreadyScheduled(time)); - m_scheduled_wakeups.erase(time); - } - -private: - // Private Methods - - // Data Members (m_ prefix) - Time m_last_scheduled_wakeup; - std::set