43 #ifndef LIB_DEL_STASH_H 44 #define LIB_DEL_STASH_H 69 typedef void KillFun(
void*);
81 Killer(KillFun* f,
void* t)
96 bool operator== (
const void* target)
const {
return target_ == target; }
97 bool operator!= (
const void* target)
const {
return target_ != target; }
102 return bool(target_);
107 typedef std::vector<Killer> Killers;
113 DelStash (
size_t elms_to_reserve =0)
118 killers_.reserve (elms_to_reserve);
128 WARN (memory,
"Problems on de-allocation: %s", errID.c());
135 size_t activeEntries = 0;
136 size_t i = killers_.size();
138 if (killers_[--i].isActive())
140 return activeEntries;
145 template<
typename TY>
150 REQUIRE (!isRegistered (obj));
151 killers_.push_back (
Killer (how_to_kill<TY>, obj));
154 template<
typename TY>
158 REQUIRE (!isRegistered (&obj));
159 killers_.push_back (
Killer (how_to_kill<TY>, &obj));
163 manage (
void* obj, KillFun* customDeleter)
166 REQUIRE (!isRegistered (obj));
167 killers_.push_back (
Killer (customDeleter, obj));
171 template<
typename TY>
179 template<
typename TY>
189 size_t i = killers_.size();
191 killers_[--i].trigger();
202 X* victim =
static_cast<X*
> (subject);
208 isRegistered (
const void* objAddress)
210 REQUIRE (objAddress);
211 return killers_.end() != findEntry (objAddress);
215 findEntry (
const void* obj)
218 return std::find (killers_.begin(),killers_.end(), obj);
222 triggerKill (
void* objAddress)
224 Killers::iterator pos = findEntry (objAddress);
225 if (killers_.end() != pos)
227 ENSURE (!isRegistered (objAddress),
"duplicate deleter registration");
Any copy and copy construction prohibited.
Implementation namespace for support and library code.
Token or Atom with distinct identity.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Marker types to indicate a literal string and a Symbol.
lumiera_err lumiera_error(void)
Get and clear current error state.
Manage a collection of deleter functions.
Lumiera error handling (C++ interface).
static void how_to_kill(void *subject)
trampoline function to invoke destructor of the specific target type