00001 /* 00002 mmapcache.h - handle aging of mmap objects 00003 00004 Copyright (C) Lumiera.org 00005 2008, Christian Thaeter <ct@pipapo.org> 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the 00010 License, or (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #ifndef LUMIERA_MMAPCACHE_H 00023 #define LUMIERA_MMAPCACHE_H 00024 00025 #include "lib/error.h" 00026 #include "lib/mrucache.h" 00027 #include "lib/mutex.h" 00028 00029 00030 typedef struct lumiera_mmapcache_struct lumiera_mmapcache; 00031 typedef lumiera_mmapcache* LumieraMMapcache; 00032 00033 #include "backend/mmap.h" 00034 00035 #include <nobug.h> 00036 00043 struct lumiera_mmapcache_struct 00044 { 00045 lumiera_mrucache cache; 00046 size_t limit; 00047 size_t total; 00048 size_t cached; 00049 lumiera_mutex lock; 00050 RESOURCE_HANDLE (rh); 00051 }; 00052 00053 extern LumieraMMapcache lumiera_mcache; 00054 00055 00060 void 00061 lumiera_mmapcache_new (size_t limit); 00062 00068 void 00069 lumiera_mmapcache_delete (void); 00070 00078 LumieraMMap 00079 lumiera_mmapcache_mmap_acquire (LumieraMMapcache self); 00080 00081 00089 void 00090 lumiera_mmapcache_announce (LumieraMMapcache self, LumieraMMap map); 00091 00099 void 00100 lumiera_mmapcache_forget (LumieraMMapcache self, LumieraMMap map); 00101 00108 int 00109 lumiera_mmapcache_age (LumieraMMapcache self); 00110 00117 LumieraMMap 00118 lumiera_mmapcache_checkout (LumieraMMapcache self, LumieraMMap handle); 00119 00126 void 00127 lumiera_mmapcache_checkin (LumieraMMapcache self, LumieraMMap handle); 00128 00129 #endif 00130 /* 00131 // Local Variables: 00132 // mode: C 00133 // c-file-style: "gnu" 00134 // indent-tabs-mode: nil 00135 // End: 00136 */
1.5.6