Skip to content

Commit 77bedc4

Browse files
committed
Make compatible with older user code by swapping exception for warning
1 parent af1900e commit 77bedc4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

include/buffer_manager.hpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ For better performance configure CPPuddle with the cmake option CPPUDDLE_DEACTIV
260260
// not enough memory left! Cleanup and attempt again:
261261
std::cerr << "Not enough memory left. Cleaning up unused buffers now..." << std::endl;
262262
buffer_recycler::clean_unused_buffers();
263+
std::cerr << "Buffers cleaned! Try allocation again..." << std::endl;
263264

264265
// If there still isn't enough memory left, the caller has to handle it
265266
// We've done all we can in here
@@ -272,6 +273,7 @@ For better performance configure CPPuddle with the cmake option CPPUDDLE_DEACTIV
272273
instance()[location_id].number_creation++;
273274
instance()[location_id].number_bad_alloc++;
274275
#endif
276+
std::cerr << "Second attempt allocation successful!" << std::endl;
275277
if (manage_content_lifetime) {
276278
std::uninitialized_value_construct_n(buffer, number_of_elements);
277279
}
@@ -334,8 +336,18 @@ For better performance configure CPPuddle with the cmake option CPPUDDLE_DEACTIV
334336
}
335337
}
336338

337-
// Failure -- something is very wrong
338-
throw std::runtime_error("Tried to delete non-existing buffer");
339+
// TODO Throw exception instead in the futures, as soon as the recycler finalize is
340+
// in all user codes
341+
/* throw std::runtime_error("Tried to delete non-existing buffer"); */
342+
343+
// This is odd: Print warning -- however, might also happen with static
344+
// buffers using these allocators IF the new finalize was not called. For
345+
// now, print warning until all user-code is upgraded to the finalize method.
346+
// This allows using current versions of cppuddle with older application code
347+
std::cerr
348+
<< "Warning! Tried to delete non-existing buffer within CPPuddle!"
349+
<< std::endl;
350+
std::cerr << "Did you forget to call recycler::finalize?" << std::endl;
339351
}
340352

341353
private:

0 commit comments

Comments
 (0)