romange / helio

A modern framework for backend development based on io_uring Linux interface
Apache License 2.0
435 stars 49 forks source link

chore: allow injection of memory_resource into accept server #223

Closed romange closed 6 months ago

romange commented 6 months ago

By default we preserve the current behavior and fallback with a memory resource that allocates using std::malloc/std::free.

Also, provide an example of how to customize memory functions for OpenSSL.

romange commented 6 months ago

yes, it's a convention from boost.fibers library

On Fri, Mar 8, 2024 at 11:29 AM Kostas Kyrimis @.***> wrote:

@.**** commented on this pull request.

LGTM

In util/fibers/detail/fiber_interface.h https://github.com/romange/helio/pull/223#discussion_r1517467016:

@@ -21,6 +22,33 @@ enum class Launch { post // enqueue the fiber for activation but continue with the current fiber. };

+// based on boost::context::fixedsize_stack but uses pmr::memory_resource for allocation. +class FixedStackAllocator {

  • public:
  • using stack_context = boost::context::stack_context;
  • FixedStackAllocator(PMR_NS::memory_resource mr, std::size_t size = 64 1024)
  • : mr(mr), size(size) {
  • }
  • stack_context allocate() {
  • void* vp = mr->allocate(size);
  • stack_context sctx;
  • sctx.size = size_;
  • sctx.sp = static_cast<char*>(vp) + sctx.size;

so the stack pointer points at the last address?

— Reply to this email directly, view it on GitHub https://github.com/romange/helio/pull/223#pullrequestreview-1924456746, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4BFCA5Z2GKEHJHHDIHR2TYXGAHXAVCNFSM6AAAAABEMPUV32VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMRUGQ2TMNZUGY . You are receiving this because you authored the thread.Message ID: @.***>

-- Best regards, Roman