diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-11-10 15:10:41 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2016-11-10 16:22:34 +0900 |
commit | 5c8dfe9873dba946a195602c60bbedc3b859c40d (patch) | |
tree | 5c73a1af71dcd71c689118b9133f25e7cc968208 | |
parent | ce3685f0017282090a70583933543c93f4bec1d3 (diff) | |
download | efl-5c8dfe9873dba946a195602c60bbedc3b859c40d.tar.gz |
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.
-rw-r--r-- | src/lib/eina/eina_freeq.c | 12 | ||||
-rw-r--r-- | src/lib/eina/eina_freeq.h | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/eina/eina_freeq.c b/src/lib/eina/eina_freeq.c index c259bd883e..49fdb0b94a 100644 --- a/src/lib/eina/eina_freeq.c +++ b/src/lib/eina/eina_freeq.c @@ -52,6 +52,7 @@ struct _Eina_FreeQ size_t mem_total; // current total memory known about in the queue Eina_FreeQ_Block *blocks; // the list of blocks of free items Eina_FreeQ_Block *block_last; // the last block to append items to + int bypass; // 0 if not to bypass, 1 if we should bypass }; // ========================================================================= // @@ -166,6 +167,7 @@ eina_freeq_new(void) eina_lock_recursive_new(&(fq->lock)); fq->count_max = _eina_freeq_total_max; fq->mem_max = _eina_freeq_mem_max; + fq->bypass = _eina_freeq_bypass; return fq; } @@ -198,6 +200,7 @@ eina_freeq_count_max_set(Eina_FreeQ *fq, int count) if (!fq) return; if (count < 0) count = 0; eina_lock_take(&(fq->lock)); + fq->bypass = 0; fq->count_max = count; _eina_freeq_flush_nolock(fq); eina_lock_release(&(fq->lock)); @@ -210,7 +213,8 @@ eina_freeq_count_max_get(Eina_FreeQ *fq) if (!fq) return 0; eina_lock_take(&(fq->lock)); - count = fq->count_max; + if (fq->bypass) count = 0; + else count = fq->count_max; eina_lock_release(&(fq->lock)); return count; } @@ -220,6 +224,7 @@ eina_freeq_mem_max_set(Eina_FreeQ *fq, size_t mem) { if (!fq) return; eina_lock_take(&(fq->lock)); + fq->bypass = 0; fq->mem_max = mem; _eina_freeq_flush_nolock(fq); eina_lock_release(&(fq->lock)); @@ -232,7 +237,8 @@ eina_freeq_mem_max_get(Eina_FreeQ *fq) if (!fq) return 0; eina_lock_take(&(fq->lock)); - mem = fq->mem_max; + if (fq->bypass) mem = 0; + else mem = fq->mem_max; eina_lock_release(&(fq->lock)); return mem; } @@ -284,7 +290,7 @@ eina_freeq_ptr_add(Eina_FreeQ *fq, if (!free_func) free_func = free; if ((size < _eina_freeq_fillpat_max) && (size > 0)) _eina_freeq_fill_do(ptr, size); - if ((!fq) || (_eina_freeq_bypass)) goto insta_free; + if ((!fq) || (fq->bypass)) goto insta_free; eina_lock_take(&(fq->lock)); if ((!fq->block_last) || (fq->block_last->end == ITEM_BLOCK_COUNT)) goto newblock; diff --git a/src/lib/eina/eina_freeq.h b/src/lib/eina/eina_freeq.h index db3d0476f5..11a0bcaf47 100644 --- a/src/lib/eina/eina_freeq.h +++ b/src/lib/eina/eina_freeq.h @@ -21,6 +21,10 @@ * * Set this environment variable to immediately bypass the free queue and * have all items submitted free with their free function immediately. + * Note that you can override this by setting count or mem max by + * eina_freeq_count_max_set() or eina_freeq_mem_max_set() which will + * disable bypass for that specific free queue. once bypass is disabled + * it cannot be re-enabled. * * EINA_FREEQ_FILL_MAX=N * |