the-moisrex / webpp

C++ web framework | web development can be done with C++ as well.
https://t.me/webpp
MIT License
132 stars 9 forks source link

Thread Local resource management #79

Open the-moisrex opened 2 years ago

the-moisrex commented 2 years ago

Okay I fixed issue #77. But the problem is I'm using a sync allocator there. I would like to use local allocators with monotonic allocators that the resource is thread local.

the-moisrex commented 2 years ago

Using an specific allocator from its features inside of a type.

Some ideas:

template <typename TT>
struct server {
  using traits_type = TT;

  template <typename T>
  using allocator = alloc::local_allocator<traits_type, T>;

  using char_allocator_type = alloc::allocator<traits_type, local_features, char>;

  using std_vec = std::vector<std::string>;
  using vec = alloc::replace_allocator<traits_type, std_vec, local_features>;

  using vec = alloc::localify<traits_type, std_vec>;

  using alloc_desc= alloc::desc<traits_type, local_fearures>;
  using alloc_desc_local = alloc::local_desc<traits_type>;

  using vec2 = typename alloc_desc::replace<std_vec>;

  vec2 v;

  server(auto&& et) : v{et.alloc_pack.template alloc_for<vec2>()} {}

  using shared_resource = object::local_resource<traits_type>;
};