30 is_wipeable_(is_wipeable),
35 AddOrRemoveDataFromCheck(data_,
false);
40 AddOrRemoveDataFromCheck(data_,
false);
46 size_t extra_bytes,
const Deleter& deleter,
bool is_wipeable,
53 DataContainer::operator
new(
sizeof(
DataContainer) + extra_bytes, alloc);
58 bool DataContainer::AddOrRemoveDataFromCheck(
void* data,
bool is_add) {
70 if (client_pointers_used->count(data)) {
71 LOG(
ERROR) <<
"Duplicate client-space pointer passed to "
72 <<
"DataContainer::Create(). This is very dangerous and may "
73 <<
"result in double-deletion! It is much safer to simply "
74 <<
"use the same DataContainerPtr.";
77 client_pointers_used->insert(data);
79 client_pointers_used->erase(data);
85 void DataContainer::InternalWipeData() {
86 if (data_ != NULL && deleter_) {
#define ION_DECLARE_SAFE_STATIC_POINTER(type, variable)
Declare a static non-array pointer and calls a default constructor.
void WipeData()
Informs the DataContainer that the data is no longer needed and can be deleted.
GenericLockGuard< port::Mutex > LockGuard
Convenient typedefs for ion::port::Mutex.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
The DataContainer class encapsulates arbitrary user data passed to Ion.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
std::function< void(void *data_to_delete)> Deleter
Generic delete function.
~DataContainer() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
kMediumTerm is used for objects that don't fall into the kShortTerm or kLongTerm categories.
DataContainer(const Deleter &deleter, bool is_wipeable)
The constructor is protected because all allocation of DataContainers should be through the Create() ...
A Mutex is used to ensure that only one thread or process can access a block of code at one time...
static const AllocatorPtr & GetDefaultAllocatorForLifetime(AllocationLifetime lifetime)