summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 15:10:41 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 16:22:34 +0900
commit5c8dfe9873dba946a195602c60bbedc3b859c40d (patch)
tree5c73a1af71dcd71c689118b9133f25e7cc968208 /src
parentce3685f0017282090a70583933543c93f4bec1d3 (diff)
eina freeq - make bypass setup only on new freeq creation and changable
this will make a freeq bypass that is enabled by using valgrind or env var not affect a freeq that has manually changed its queue count max or mem max. these now become explicit deferred freeers.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_freeq.c12
-rw-r--r--src/lib/eina/eina_freeq.h4
2 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/eina/eina_freeq.c b/src/lib/eina/eina_freeq.c
index c259bd8..49fdb0b 100644
--- a/src/lib/eina/eina_freeq.c
+++ b/src/lib/eina/eina_freeq.c
@@ -52,6 +52,7 @@ struct _Eina_FreeQ
52 size_t mem_total; // current total memory known about in the queue 52 size_t mem_total; // current total memory known about in the queue
53 Eina_FreeQ_Block *blocks; // the list of blocks of free items 53 Eina_FreeQ_Block *blocks; // the list of blocks of free items
54 Eina_FreeQ_Block *block_last; // the last block to append items to 54 Eina_FreeQ_Block *block_last; // the last block to append items to
55 int bypass; // 0 if not to bypass, 1 if we should bypass
55}; 56};
56 57
57// ========================================================================= // 58// ========================================================================= //
@@ -166,6 +167,7 @@ eina_freeq_new(void)
166 eina_lock_recursive_new(&(fq->lock)); 167 eina_lock_recursive_new(&(fq->lock));
167 fq->count_max = _eina_freeq_total_max; 168 fq->count_max = _eina_freeq_total_max;
168 fq->mem_max = _eina_freeq_mem_max; 169 fq->mem_max = _eina_freeq_mem_max;
170 fq->bypass = _eina_freeq_bypass;
169 return fq; 171 return fq;
170} 172}
171 173
@@ -198,6 +200,7 @@ eina_freeq_count_max_set(Eina_FreeQ *fq, int count)
198 if (!fq) return; 200 if (!fq) return;
199 if (count < 0) count = 0; 201 if (count < 0) count = 0;
200 eina_lock_take(&(fq->lock)); 202 eina_lock_take(&(fq->lock));
203 fq->bypass = 0;
201 fq->count_max = count; 204 fq->count_max = count;
202 _eina_freeq_flush_nolock(fq); 205 _eina_freeq_flush_nolock(fq);
203 eina_lock_release(&(fq->lock)); 206 eina_lock_release(&(fq->lock));
@@ -210,7 +213,8 @@ eina_freeq_count_max_get(Eina_FreeQ *fq)
210 213
211 if (!fq) return 0; 214 if (!fq) return 0;
212 eina_lock_take(&(fq->lock)); 215 eina_lock_take(&(fq->lock));
213 count = fq->count_max; 216 if (fq->bypass) count = 0;
217 else count = fq->count_max;
214 eina_lock_release(&(fq->lock)); 218 eina_lock_release(&(fq->lock));
215 return count; 219 return count;
216} 220}
@@ -220,6 +224,7 @@ eina_freeq_mem_max_set(Eina_FreeQ *fq, size_t mem)
220{ 224{
221 if (!fq) return; 225 if (!fq) return;
222 eina_lock_take(&(fq->lock)); 226 eina_lock_take(&(fq->lock));
227 fq->bypass = 0;
223 fq->mem_max = mem; 228 fq->mem_max = mem;
224 _eina_freeq_flush_nolock(fq); 229 _eina_freeq_flush_nolock(fq);
225 eina_lock_release(&(fq->lock)); 230 eina_lock_release(&(fq->lock));
@@ -232,7 +237,8 @@ eina_freeq_mem_max_get(Eina_FreeQ *fq)
232 237
233 if (!fq) return 0; 238 if (!fq) return 0;
234 eina_lock_take(&(fq->lock)); 239 eina_lock_take(&(fq->lock));
235 mem = fq->mem_max; 240 if (fq->bypass) mem = 0;
241 else mem = fq->mem_max;
236 eina_lock_release(&(fq->lock)); 242 eina_lock_release(&(fq->lock));
237 return mem; 243 return mem;
238} 244}
@@ -284,7 +290,7 @@ eina_freeq_ptr_add(Eina_FreeQ *fq,
284 if (!free_func) free_func = free; 290 if (!free_func) free_func = free;
285 if ((size < _eina_freeq_fillpat_max) && (size > 0)) 291 if ((size < _eina_freeq_fillpat_max) && (size > 0))
286 _eina_freeq_fill_do(ptr, size); 292 _eina_freeq_fill_do(ptr, size);
287 if ((!fq) || (_eina_freeq_bypass)) goto insta_free; 293 if ((!fq) || (fq->bypass)) goto insta_free;
288 eina_lock_take(&(fq->lock)); 294 eina_lock_take(&(fq->lock));
289 if ((!fq->block_last) || (fq->block_last->end == ITEM_BLOCK_COUNT)) 295 if ((!fq->block_last) || (fq->block_last->end == ITEM_BLOCK_COUNT))
290 goto newblock; 296 goto newblock;
diff --git a/src/lib/eina/eina_freeq.h b/src/lib/eina/eina_freeq.h
index db3d047..11a0bca 100644
--- a/src/lib/eina/eina_freeq.h
+++ b/src/lib/eina/eina_freeq.h
@@ -21,6 +21,10 @@
21 * 21 *
22 * Set this environment variable to immediately bypass the free queue and 22 * Set this environment variable to immediately bypass the free queue and
23 * have all items submitted free with their free function immediately. 23 * have all items submitted free with their free function immediately.
24 * Note that you can override this by setting count or mem max by
25 * eina_freeq_count_max_set() or eina_freeq_mem_max_set() which will
26 * disable bypass for that specific free queue. once bypass is disabled
27 * it cannot be re-enabled.
24 * 28 *
25 * EINA_FREEQ_FILL_MAX=N 29 * EINA_FREEQ_FILL_MAX=N
26 * 30 *