1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
46 #include "OSGConfig.h"
47 #include "OSGBaseThread.h"
48 #include "OSGThreadManager.h"
49 #include "OSGSocketSelection.h"
50 #include "OSGDgramQueue.h"
54 /** \class OSG::DgramQueue
55 * \brief Stream socket connection
59 /*-------------------------------------------------------------------------*/
60 /* constructor destructor */
66 DgramQueue::DgramQueue():
71 char barrierName
[256];
72 sprintf(barrierName
,"DgramQueue%p", static_cast<void *>(this));
75 _barrier
= Barrier::get(barrierName
, false);
80 DgramQueue::~DgramQueue()
85 /*-------------------------------------------------------------------------*/
88 /*! put a dgram to the queue.
90 void DgramQueue::put( Dgram
*dgram
)
92 _queue
.push_back(dgram
);
100 /*! get a dgram from the queue. Block if queue is empty
102 Dgram
*DgramQueue::get( Lock
*lock
)
113 result
= _queue
.front();
119 /*! wait for a dgram but dont read
121 void DgramQueue::wait( Lock
*lock
)
132 /*! true, if reader is waiting
134 bool DgramQueue::waiting(void)
139 bool DgramQueue::empty(void)
141 return _queue
.empty();