The reason is that each thread can obtain its own distinct and therefore
safe allocator.

The model is such that when the thread for finishes a unit of work, it
returns the memory to the thread's allocator for the next unit of work.

The alternative is the malloc/free model which you are used to, which has
performance penalties for allocating from a common and therefore
contested/mutexed resource.

Hope this explanation is helpful. We can and should do a better job of
documenting such, Nick may have a chapter in his APR book on the subject.

On Jan 15, 2017 14:16, "Sergey Safarov" <s.safa...@gmail.com> wrote:

Could you help me understand why not used mutex to implement thread safety
functions:

   1. apr_palloc
   2. apr_pool_clear
   3. apr_pool_destroy
   4. apr_pvsprintf


In this functions is used:

   1. pool_concurrency_set_used
   2. pool_concurrency_set_idle
   3. pool_concurrency_set_destroyed

And if concurrency access is detected then called "pool_concurrency_abort"
and program terminated.

https://github.com/apache/apr/blob/trunk/memory/unix/apr_pools.c

Reply via email to