aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/stack/stack_allocator.cpp
blob: bf12134e6b63e887480c06227397a9bff0512905 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stack_allocator.h"


namespace NCoro::NStack {

    THolder<IAllocator> GetAllocator(TMaybe<TPoolAllocatorSettings> poolSettings, EGuard guardType) {
        THolder<IAllocator> allocator;
        if (poolSettings) {
            if (guardType == EGuard::Canary) {
                allocator = MakeHolder<TPoolAllocator<TCanaryGuard>>(*poolSettings);
            } else {
                Y_ASSERT(guardType == EGuard::Page);
                allocator = MakeHolder<TPoolAllocator<TPageGuard>>(*poolSettings);
            }
        } else {
            if (guardType == EGuard::Canary) {
                allocator = MakeHolder<TSimpleAllocator<TCanaryGuard>>();
            } else {
                Y_ASSERT(guardType == EGuard::Page);
                allocator = MakeHolder<TSimpleAllocator<TPageGuard>>();
            }
        }
        return allocator;
    }

}