Consumer.hh revision 6154
16129Snate@binkert.org
26129Snate@binkert.org/*
36129Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
46129Snate@binkert.org * All rights reserved.
56129Snate@binkert.org *
66129Snate@binkert.org * Redistribution and use in source and binary forms, with or without
76129Snate@binkert.org * modification, are permitted provided that the following conditions are
86129Snate@binkert.org * met: redistributions of source code must retain the above copyright
96129Snate@binkert.org * notice, this list of conditions and the following disclaimer;
106129Snate@binkert.org * redistributions in binary form must reproduce the above copyright
116129Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
126129Snate@binkert.org * documentation and/or other materials provided with the distribution;
136129Snate@binkert.org * neither the name of the copyright holders nor the names of its
146129Snate@binkert.org * contributors may be used to endorse or promote products derived from
156129Snate@binkert.org * this software without specific prior written permission.
166129Snate@binkert.org *
176129Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186129Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196129Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206129Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216129Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226129Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236129Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246129Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256129Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266129Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276129Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286129Snate@binkert.org */
296129Snate@binkert.org
306129Snate@binkert.org/*
316169Snate@binkert.org * $Id$
326169Snate@binkert.org *
336169Snate@binkert.org * Description: This is the virtual base class of all classes that can
348229Snate@binkert.org * be the targets of wakeup events.  There is only two methods,
356130Snate@binkert.org * wakeup() and print() and no data members.
366129Snate@binkert.org *
376129Snate@binkert.org */
386129Snate@binkert.org
396130Snate@binkert.org#ifndef CONSUMER_H
406130Snate@binkert.org#define CONSUMER_H
416130Snate@binkert.org
426130Snate@binkert.org#include "mem/ruby/common/Global.hh"
436130Snate@binkert.org#include "mem/ruby/eventqueue/RubyEventQueue.hh"
446130Snate@binkert.org
456130Snate@binkert.orgclass MessageBuffer;
466130Snate@binkert.org
477462Snate@binkert.orgclass Consumer {
486130Snate@binkert.orgpublic:
496130Snate@binkert.org  // Constructors
506130Snate@binkert.org  Consumer() { m_last_scheduled_wakeup = 0; m_last_wakeup = 0; m_out_link_vec.setSize(0); }
516130Snate@binkert.org
526130Snate@binkert.org  // Destructor
536130Snate@binkert.org  virtual ~Consumer() { }
546130Snate@binkert.org
556130Snate@binkert.org  // Public Methods - pure virtual methods
566130Snate@binkert.org  void triggerWakeup() { Time time = g_eventQueue_ptr->getTime(); if (m_last_wakeup != time) { wakeup(); m_last_wakeup = time; }}
576130Snate@binkert.org  virtual void wakeup() = 0;
586130Snate@binkert.org  virtual void print(ostream& out) const = 0;
596130Snate@binkert.org  const Time& getLastScheduledWakeup() const { return m_last_scheduled_wakeup; }
609743Snilay@cs.wisc.edu  void setLastScheduledWakeup(const Time& time) { m_last_scheduled_wakeup = time; }
619743Snilay@cs.wisc.edu  Vector< Vector<MessageBuffer*> > getOutBuffers() { return m_out_link_vec; }
626130Snate@binkert.org
636130Snate@binkert.orgprotected:
647462Snate@binkert.org  Vector< Vector<MessageBuffer*> > m_out_link_vec;
656130Snate@binkert.org
667505Snate@binkert.orgprivate:
678296Snate@binkert.org  // Private Methods
686129Snate@binkert.org
696129Snate@binkert.org  // Data Members (m_ prefix)
706129Snate@binkert.org  Time m_last_scheduled_wakeup;
716129Snate@binkert.org  Time m_last_wakeup;
726129Snate@binkert.org};
736129Snate@binkert.org
748243Sbradley.danofsky@amd.com// Output operator declaration
758243Sbradley.danofsky@amd.cominline extern
766129Snate@binkert.orgostream& operator<<(ostream& out, const Consumer& obj);
776129Snate@binkert.org
786129Snate@binkert.org// ******************* Definitions *******************
796130Snate@binkert.org
806129Snate@binkert.org// Output operator definition
816129Snate@binkert.orginline extern
826129Snate@binkert.orgostream& operator<<(ostream& out, const Consumer& obj)
836129Snate@binkert.org{
846129Snate@binkert.org  obj.print(out);
856129Snate@binkert.org  out << flush;
866129Snate@binkert.org  return out;
876129Snate@binkert.org}
886129Snate@binkert.org
896129Snate@binkert.org#endif //CONSUMER_H
906129Snate@binkert.org