CPN
Computational Process Networks
D4RQueue.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
23 #ifndef D4R_QUEUE_H
24 #define D4R_QUEUE_H
25 #pragma once
26 #include <cpn/common.h>
27 #include <tr1/memory>
28 namespace D4R {
29 
30  using std::tr1::shared_ptr;
31 
32  class Node;
33 
39  class QueueBase {
40  public:
41  QueueBase();
42  virtual ~QueueBase();
43 
48  void SetReaderNode(shared_ptr<Node> n);
53  void SetWriterNode(shared_ptr<Node> n);
54 
55  protected:
63  void ReadBlock();
64 
71  void WriteBlock(unsigned qsize);
72 
76  virtual bool ReadBlocked() = 0;
80  virtual bool WriteBlocked() = 0;
81 
86  virtual void Detect() = 0;
87 
88  public:
93  virtual void Lock() const = 0;
94  virtual void Unlock() const = 0;
102  void SignalReaderTagChanged();
103  void SignalWriterTagChanged();
105  private:
106  QueueBase(const QueueBase&);
107  QueueBase &operator=(const QueueBase&);
108 
109  protected:
110  virtual void UnlockedSignalReaderTagChanged();
111  virtual void UnlockedSignalWriterTagChanged();
116  virtual void Wait() = 0;
120  virtual void Signal() = 0;
121 
122  shared_ptr<Node> reader;
123  shared_ptr<Node> writer;
126  bool incomm;
127  };
128 
129 }
130 #endif
virtual void Detect()=0
shared_ptr< Node > reader
Definition: D4RQueue.h:122
virtual bool WriteBlocked()=0
void SetReaderNode(shared_ptr< Node > n)
Definition: D4RQueue.cc:59
virtual void Lock() const =0
virtual void Wait()=0
shared_ptr< Node > writer
Definition: D4RQueue.h:123
virtual bool ReadBlocked()=0
void SignalWriterTagChanged()
Definition: D4RQueue.cc:150
void WriteBlock(unsigned qsize)
Definition: D4RQueue.cc:106
virtual void Unlock() const =0
void SignalReaderTagChanged()
Definition: D4RQueue.cc:139
virtual ~QueueBase()
Definition: D4RQueue.cc:57
virtual void UnlockedSignalReaderTagChanged()
Definition: D4RQueue.cc:144
virtual void UnlockedSignalWriterTagChanged()
Definition: D4RQueue.cc:155
void ReadBlock()
Definition: D4RQueue.cc:71
bool readtagchanged
Definition: D4RQueue.h:124
virtual void Signal()=0
void SetWriterNode(shared_ptr< Node > n)
Definition: D4RQueue.cc:65
bool writetagchanged
Definition: D4RQueue.h:125
QueueBase & operator=(const QueueBase &)