FastFlow  SVN-r182-Aug-14-2014
A high-level, lock-less, parallel programming (shared-memory) and distributed programming (distributed-memory) framework for multi-cores and many-cores systems
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
Classes | Namespaces
allocator.hpp File Reference

Implementations of the FastFlow's lock-free allocator. More...

#include <assert.h>
#include <algorithm>
#include <ff/platforms/platform.h>
#include <ff/atomic/atomic.h>
#include <ff/buffer.hpp>
#include <ff/ubuffer.hpp>
#include <ff/spin-lock.hpp>
#include <ff/svector.hpp>
#include <ff/utils.hpp>
+ Include dependency graph for allocator.hpp:
+ This graph shows which files directly or indirectly include this file:


class  ff::ff_allocator
 The ff_allocator, based on the idea of the Slab allocator More...
class  ff::FFAllocator
 A user-space parallel allocator (process-wide) More...


 The principal namespace for the FastFlow library.

Detailed Description

Implementations of the FastFlow's lock-free allocator.

Here we defined the ff::ff_allocator (1) and the ff::FFAllocator (2).

  1. The ff_allocator allocates only large chunks of memory, slicing them up into little chunks all with the same size. Only one thread can perform malloc operations while any number of threads may perform frees using the ff_allocator.

    The ff_allocator is based on the idea of Slab Allocator, for more details about Slab Allocator please see: Bonwick, Jeff. "The Slab Allocator: An Object-Caching Kernel Memory Allocator." Boston USENIX Proceedings, 1994.

  2. Based on the ff_allocator, the FFAllocator has been implemented. It might be used by any number of threads to dynamically allocate/deallocate memory. You have to include allocator.hpp and just use ff::ff_malloc, ff::ff_free(), ff::ff_realloc, ff::ff_posix_memalign
In all the cases it is possible, it is better to use the ff_allocator as it allows more control and is more efficient.