00001 /* 00002 * Copyright (C) 2006, Jose Renato Santos. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 */ 00017 00018 /////////////////////////////////////////////////////////////////////////////// 00019 // riofreelist.h -- free list primitives for pthreads 00020 /////////////////////////////////////////////////////////////////////////////// 00021 00022 #ifndef __RIOFREELIST_H_ 00023 #define __RIOFREELIST_H_ 00024 00025 #include <vsicondition.h> 00026 00027 // for RioQueueEle 00028 #include <rioqueue.h> 00029 00030 /////////////////////////////////////////////////////////////////////////////// 00031 class CRioFreeList 00032 { 00033 public: 00034 CRioFreeList(); 00035 ~CRioFreeList(); 00036 void Free(RioQueueEle *ep); // add element to free list 00037 00038 RioQueueEle *Get(); // wait for available element 00039 // and remove it from free list 00040 RioQueueEle *GetNB(); // remove element from free list 00041 // if available. Return null otherwise 00042 private: 00043 CvsiCondition m_cond; 00044 int m_waitflag; 00045 RioQueueEle *m_first; 00046 }; 00047 00048 #endif //__RIOFREELIST_H_ 00049