00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 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 * Thanks: Jose Renato Santos 00017 * 00018 */ 00019 00020 /////////////////////////////////////////////////////////////////////////////// 00021 // localqueue.h: double linked fifo queue primitives to be used in a 00022 // single thread (i.e. no mutex) 00023 /////////////////////////////////////////////////////////////////////////////// 00024 00025 #ifndef __LOCALQUEUE_H_ 00026 #define __LOCALQUEUE_H_ 00027 00028 #include <pthread.h> 00029 00030 // queue element structure 00031 class LocalQueueEle 00032 { 00033 public: 00034 LocalQueueEle *linkf; 00035 LocalQueueEle *linkb; 00036 00037 LocalQueueEle() 00038 { 00039 linkf = NULL; 00040 linkb = NULL; 00041 } 00042 }; 00043 00044 /////////////////////////////////////////////////////////////////////////////// 00045 00046 class LocalQueue 00047 { 00048 00049 public: 00050 LocalQueue(); 00051 ~LocalQueue(); 00052 LocalQueueEle *First(); // return first element on queue 00053 // (Do not remove element) 00054 void Put( LocalQueueEle *ep ); // add element to end of queue 00055 LocalQueueEle *Get(); // get first element 00056 void Remove( LocalQueueEle *ep );// Remove an element from queue 00057 00058 private: 00059 LocalQueueEle m_Head; 00060 }; 00061 #endif //_LOCALQUEUE_H__