00001 // -*- C++ -*- 00002 // 00003 // Copyright (c) 2006 by Rafael Ostertag 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // 00020 // $Id: casgarbage.h,v 1.11 2006/12/31 00:48:15 rafi Exp $ 00021 // 00022 00042 #ifndef _CASGARBAGE_H 00043 #define _CASGARBAGE_H 00044 00045 #ifdef HAVE_CONFIG_H 00046 #include "config.h" 00047 #endif 00048 00049 #include <pthread.h> 00050 #include <cerrno> 00051 00052 #include <vector> 00053 #include <list> 00054 00055 #include "casobject.h" 00056 #include "casexception.h" 00057 #include "casfuncobj.h" 00058 00081 class CASGarbage { 00082 private: 00089 const unsigned long min_casobjects; 00095 pthread_t tid; 00101 pthread_attr_t pattr; 00107 pthread_mutexattr_t mutex_attr; 00113 pthread_mutex_t mutex; 00119 pthread_cond_t cond_var; 00125 bool time_to_die; 00133 bool trasher_thread_created; 00139 std::vector<CASObject*> list; 00140 00144 void CreateTrasherThread(); 00148 void TerminateTrasherThread(); 00153 void RemoveDuplicate(); 00157 void CheckRetVal ( int rv, std::string fname ); 00158 public: 00162 CASGarbage(); 00166 ~CASGarbage(); 00170 CASGarbage( const CASGarbage &wdc); 00171 00176 void* Trasher(); 00180 void Put ( CASObject *o ); 00185 void Put ( const std::vector<CASObject*> &v ); 00190 void Put ( const std::list<CASObject*> &l ); 00191 00195 CASGarbage &operator=( const CASGarbage &wdc); 00196 }; 00197 00202 #endif /* _CASGARBAGE_H */
1.4.7