The main motivation for reusing objects is that it helps to avoid creating and leaking synchronization clocks in TSan. The reused object will reuse the synchronization clock in TSan.
Before, new and delete operator were overloaded to get and return memory for the object from/to the object pool.
This patch replaces the operator overloading with explicit static New/Delete functions.
Objects for parallel regions and implicit tasks will always be recruited and returned to the thread-local object pool. Only for explicit task, there is a chance that an other thread completes the task and will free the object. This patch optimizes the thread-local New/Delete calls by avoiding locks and only lock if the pool is empty. Remote threads return the object into a separate queue.
The chunk size for allocations is now decided based on page size. The objects will also be aligned to cache lines avoiding false sharing.
This is the first patch in a series to provide better tasking support.
Shouldn't be virtual, the idea of CRTP is that you can do without. Reset can be called after static_cast<T *>