A Fast Multi-Threading Memory Allocator
Keywords: fast multi-threading memory allocator allocation syntax purpose include

| Prev | Next |  |  |  |  |  |

A Fast Multi-Threading Memory Allocator
Syntax `
# include <cppad/thread_alloc.hpp>`
Purpose
The C++ `new` and `delete` operators are thread safe, but this means that a thread may have to wait for a lock on these operations. Once memory is obtained for a thread, the `thread_alloc` memory allocator keeps that memory available for the thread so that it can be re-used without waiting for a lock. All the CppAD memory allocations use this utility. The free_available function should be used to return memory to the system (once it is no longer required by a thread).
Include
The routines in sections below are defined by `cppad/thread_alloc.hpp`. This file is included by `cppad/cppad.hpp`, but it can also be included separately with out the rest of the `CppAD`.
Contents

thread_alloc.cpp | Fast Multi-Threading Memory Allocator: Example and Test
ta_parallel_setup | Setup thread_alloc For Use in Multi-Threading Environment
ta_num_threads | Get Number of Threads
ta_in_parallel | Is The Current Execution in Parallel Mode
ta_thread_num | Get the Current Thread Number
ta_get_memory | Get At Least A Specified Amount of Memory
ta_return_memory | Return Memory to thread_alloc
ta_free_available | Free Memory Currently Available for Quick Use by a Thread
ta_hold_memory | Control When Thread Alloc Retains Memory For Future Use
ta_inuse | Amount of Memory a Thread is Currently Using
ta_available | Amount of Memory Available for Quick Use by a Thread
ta_create_array | Allocate An Array and Call Default Constructor for its Elements
ta_delete_array | Deallocate An Array and Call Destructor for its Elements
ta_free_all | Free All Memory That Was Allocated for Use by thread_alloc

Input File: omh/thread_alloc.omh