Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/net/datagramQueue.h

Go to the documentation of this file.
00001 // Filename: datagramQueue.h
00002 // Created by:  drose (07Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef DATAGRAMQUEUE_H
00020 #define DATAGRAMQUEUE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "netDatagram.h"
00025 
00026 #include <prlock.h>
00027 #include <prcvar.h>
00028 #include "pdeque.h"
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : DatagramQueue
00032 // Description : A thread-safe, FIFO queue of NetDatagrams.  This is used
00033 //               by ConnectionWriter for queuing up datagrams for
00034 //               its various threads to write to sockets.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA DatagramQueue {
00037 public:
00038   DatagramQueue();
00039   ~DatagramQueue();
00040   void shutdown();
00041 
00042   bool insert(const NetDatagram &data);
00043   bool extract(NetDatagram &result);
00044 
00045   void set_max_queue_size(int max_size);
00046   int get_max_queue_size() const;
00047   int get_current_queue_size() const;
00048 
00049 private:
00050   PRLock *_cvlock;
00051   PRCondVar *_cv;
00052 
00053 #ifdef __ICL
00054   // The Intel compiler for some reason dumps core on a queue of
00055   // NetDatagrams.
00056   typedef pdeque<NetDatagram *> QueueType;
00057 #else
00058   typedef pdeque<NetDatagram> QueueType;
00059 #endif
00060 
00061   QueueType _queue;
00062   bool _shutdown;
00063   int _max_queue_size;
00064 };
00065 
00066 #endif
00067 

Generated on Fri May 2 00:40:34 2003 for Panda by doxygen1.3