src/ucx/mempool.h

changeset 326
3dd7d21fb76b
parent 259
2f5dea574a75
     1.1 --- a/src/ucx/mempool.h	Tue May 29 11:05:12 2018 +0200
     1.2 +++ b/src/ucx/mempool.h	Wed May 30 11:13:52 2018 +0200
     1.3 @@ -164,6 +164,9 @@
     1.4   * 
     1.5   * The destructor is automatically called when the memory is freed or the
     1.6   * pool is destroyed.
     1.7 + * A destructor for pooled memory <b>MUST NOT</b> free the memory itself,
     1.8 + * as this is done by the pool. Use a destructor to free any resources
     1.9 + * managed by the pooled object.
    1.10   * 
    1.11   * The only requirement for the specified memory is, that it <b>MUST</b> be
    1.12   * pooled memory by a UcxMempool or an element-compatible mempool. The pointer
    1.13 @@ -179,12 +182,18 @@
    1.14  
    1.15  /**
    1.16   * Registers a destructor function for the specified (non-pooled) memory.
    1.17 - * 
    1.18 + *
    1.19   * This is useful, if you have memory that has not been allocated by a mempool,
    1.20   * but shall be managed by a mempool.
    1.21   * 
    1.22   * This function creates an entry in the specified mempool and the memory will
    1.23   * therefore (logically) convert to pooled memory.
    1.24 + * <b>However, this does not cause the memory to be freed automatically!</b>.
    1.25 + * If you want to use this function, make the memory pool free non-pooled
    1.26 + * memory, the specified destructor function must call <code>free()</code>
    1.27 + * by itself. But keep in mind, that you then MUST NOT use this destructor
    1.28 + * function with pooled memory (e.g. in ucx_mempool_set_destr()), as it
    1.29 + * would cause a double-free.
    1.30   * 
    1.31   * @param pool the memory pool
    1.32   * @param ptr data the destructor is registered for

mercurial