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

GC.H

00001 /* $Id: GC.H,v 1.2 2000/11/03 22:03:28 rpav Exp $
00002  *
00003  * SFW - Studio FrameWork
00004  * Copyright (C) 2000  Ryan Pavlik
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  *
00020  */
00021 
00022 #ifndef GC_H
00023 #define GC_H
00024 
00025 #include <map>
00026 #include <SFW/Object.H>
00027 #include <SFW/Thread.H>
00028 
00029 namespace SFW {
00030     class _GC : public Thread {
00031     typedef map<Object*,  unsigned int> RefMap;
00032     RefMap refmap;
00033 
00034     Mutex m;
00035 
00036     public:
00037     TYPE_INFO(SFW::_GC, SFW::Thread);
00038 
00039         _GC();
00040 
00041     void use(Object *o);
00042     void done(Object *o);
00043         void finalize();
00044 
00045     /* These are aliases, and should be used when
00046      * you're explicitly altering the refcount for
00047      * some good reason.
00048      */
00049     inline void incref(Object *_o) {  use(_o); }
00050     inline void decref(Object *_o) { done(_o); }
00051 
00052     void collect();
00053 
00054     /* If run, sit in the background and collect()
00055      * every once in awhile
00056      */
00057     void main();
00058     };
00059 
00060     extern _GC GC;
00061 }
00062 
00063 #endif /* GC_H */

Generated at Tue Jan 2 15:38:33 2001 for SFW by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000