Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef _ink_queue_ext_h_
00025 #define _ink_queue_ext_h_
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 #include "List.h"
00034 #include "ink_queue.h"
00035 
00036 #ifdef __cplusplus
00037 extern "C"
00038 {
00039 #endif                          
00040 #if TS_USE_RECLAIMABLE_FREELIST
00041   struct _InkThreadCache;
00042   struct _InkFreeList;
00043 
00044   typedef struct _InkChunkInfo
00045   {
00046     pthread_t tid;
00047 
00048     uint32_t type_size;
00049     uint32_t chunk_size;
00050     uint32_t allocated;
00051     uint32_t length;
00052 
00053     
00054 
00055 
00056 
00057     void *inner_free_list;
00058     void *head;
00059 
00060     struct _InkThreadCache *pThreadCache;
00061 
00062     LINK(_InkChunkInfo, link);
00063 
00064 #ifdef DEBUG
00065     
00066 
00067 
00068 
00069     unsigned char item_magic[0];
00070 #endif
00071   } InkChunkInfo;
00072 
00073   typedef struct _InkThreadCache
00074   {
00075     struct _InkFreeList *f;
00076 
00077     
00078 
00079 
00080 
00081 
00082     InkAtomicList outer_free_list;
00083 
00084     
00085     float nr_average;
00086     uint32_t nr_total;
00087     uint32_t nr_free;
00088     uint32_t nr_min;
00089     uint32_t nr_overage;
00090     uint32_t nr_malloc;
00091 
00092     
00093 
00094 
00095 
00096     uint32_t status;
00097 
00098     uint32_t nr_free_chunks;
00099     DLL<InkChunkInfo> free_chunk_list;
00100 
00101     _InkThreadCache *prev, *next;
00102   } InkThreadCache;
00103 
00104   typedef struct _InkFreeList
00105   {
00106     uint32_t thread_cache_idx;
00107 
00108     uint32_t refcnt;
00109     const char *name;
00110 
00111     uint32_t type_size;
00112     uint32_t alignment;
00113 
00114     
00115     uint32_t chunk_size;
00116     
00117     uint32_t chunk_byte_size;
00118     
00119     uintptr_t chunk_addr_mask;
00120 
00121     uint32_t used;
00122     uint32_t allocated;
00123     uint32_t allocated_base;
00124     uint32_t used_base;
00125     uint32_t chunk_size_base;
00126 
00127     uint32_t nr_thread_cache;
00128     InkThreadCache *pThreadCache;
00129     ink_mutex lock;
00130   } InkFreeList, *PInkFreeList;
00131 
00132   
00133   void reclaimable_freelist_init(InkFreeList **fl, const char *name,
00134                                  uint32_t type_size, uint32_t chunk_size,
00135                                  uint32_t alignment);
00136   void *reclaimable_freelist_new(InkFreeList *f);
00137   void reclaimable_freelist_free(InkFreeList *f, void *item);
00138 #endif 
00139 #ifdef __cplusplus
00140 }
00141 #endif 
00142 
00143 #endif