Add element construction/destruction hooks to IndexedMemPool
authorVictor Zverovich <viz@fb.com>
Tue, 6 Jun 2017 20:10:49 +0000 (13:10 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 6 Jun 2017 20:20:33 +0000 (13:20 -0700)
commit1e6a1dce8fa0c0132661a4858b422be14c425dad
tree9741e2f39ac2e86dc6b94a6eaf29d327fef5915c
parent111b7bcce01b04e884a77248124c64a7aa337ade
Add element construction/destruction hooks to IndexedMemPool

Summary: This diff adds a Traits template parameter to IndexedMemPool that allows more control over the lifetime management of individual elements, including mixes of lazy and eager recycle semantics (or colocation of different classes of data inside a single element). It also arranges that an index is not reported as isAllocated() until it has been passed to Traits::initialize and passed to Traits::onAllocate at least once, so code that is traversing valid indexes doesn't need to deal with the post-initialize but pre-onAllocate state (it must still deal with indexes that reported isAllocated() as true but have since been passed to onRecycle). The default behavior is unchanged.

Reviewed By: nbronson

Differential Revision: D5177462

fbshipit-source-id: e7d22c860ab6bf25083977dfb5a63955641c9cfb
folly/IndexedMemPool.h
folly/experimental/flat_combining/FlatCombining.h
folly/test/IndexedMemPoolTest.cpp