Skip to content
Snippets Groups Projects
Commit cdf7ec5b authored by Recolic K's avatar Recolic K
Browse files

update-catch

parent 8eaaf90d
No related branches found
No related tags found
No related merge requests found
Pipeline #897 failed with stage
......@@ -13,13 +13,15 @@ namespace rlib {
class traceable_list {
struct node {
/*
* You may not manage data ownness here. Or you must carefully check if (node*)&data works.
* You may not manage data ownership here. Or you must carefully check if (node*)&data works.
*/
T data; // Able to get iterator from T*
node *prev;
node *next;
extra_info_t extra_info; // bool flag. specially designed for object_pool.
#if DEBUG
uint32_t magic = 0x19990823;
#endif
template <typename... TConstructArgs>
node(node *prev, node *next, const extra_info_t &extra_info, TConstructArgs... args)
: data(std::forward<TConstructArgs>(args) ...), prev(prev), next(next), extra_info(extra_info)
......@@ -36,9 +38,11 @@ namespace rlib {
explicit iterator(node *ptr) : ptr(ptr) {}
explicit iterator(T *data_pointer) : ptr(reinterpret_cast<node *>(data_pointer)) {
#if DEBUG
if (ptr->magic != 0x19990823)
throw std::invalid_argument(
"magic_num verification failed. invalid data_pointer passed or ruined memory?");
#endif
}
T &operator*() {
......
......@@ -21,6 +21,7 @@
using size_t = unsigned long;
namespace rlib {
// Policy object can be stateful.
struct object_pool_policy_fixed {
object_pool_policy_fixed(size_t size) : size(size) {}
size_t objects_should_alloc(const size_t inuse_objects, const size_t avail_objects) const {
......@@ -46,6 +47,7 @@ namespace rlib {
const size_t min_objects;
};
struct object_pool_policy_dynamic_smart {
// TODO
};
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment