aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/coroutine/engine/sockmap.h
blob: 193ec2261bec61976aedcdbe6a3f3fce0c94fdbb (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
#pragma once

#include <util/generic/hash.h>
#include <util/generic/vector.h>

template <class T>
class TSocketMap {
public:
    T& Get(size_t idx) {
        if (idx < 128000) {
            if (V_.size() <= idx) {
                V_.resize(idx + 1);
            }

            return V_[idx];
        }

        return H_[idx];
    }

private:
    TVector<T> V_; 
    THashMap<size_t, T> H_; 
};