aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/interconnect/poller_tcp.cpp
blob: 456bca8b9875eae93f2a91472be6e90fc08890dd (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
27
28
29
30
31
32
33
34
35
#include "poller_tcp.h"

namespace NInterconnect {
    TPollerThreads::TPollerThreads(size_t units, bool useSelect) 
        : Units(units) 
    { 
        Y_VERIFY_DEBUG(!Units.empty()); 
        for (auto& unit : Units) 
            unit = TPollerUnit::Make(useSelect); 
    } 

    TPollerThreads::~TPollerThreads() { 
    } 

    void TPollerThreads::Start() { 
        for (const auto& unit : Units) 
            unit->Start(); 
    } 

    void TPollerThreads::Stop() { 
        for (const auto& unit : Units) 
            unit->Stop(); 
    } 

    void TPollerThreads::StartRead(const TIntrusivePtr<TSharedDescriptor>& s, TFDDelegate&& operation) { 
        auto& unit = Units[THash<SOCKET>()(s->GetDescriptor()) % Units.size()]; 
        unit->StartReadOperation(s, std::move(operation)); 
    } 

    void TPollerThreads::StartWrite(const TIntrusivePtr<TSharedDescriptor>& s, TFDDelegate&& operation) { 
        auto& unit = Units[THash<SOCKET>()(s->GetDescriptor()) % Units.size()]; 
        unit->StartWriteOperation(s, std::move(operation)); 
    } 

}