MCPcopy Create free account
hub / github.com/catboost/catboost / Purge

Method Purge

library/cpp/neh/conn_cache.h:91–119  ·  view source on GitHub ↗

close/remove part of the connections from cache

Source from the content-addressed store, hash-verified

89
90 //close/remove part of the connections from cache
91 size_t Purge(size_t addrId, size_t frac256) {
92 TConnList& cl = Lst_.Get(addrId);
93 size_t qsize = cl.Size();
94 if (!qsize) {
95 return 0;
96 }
97
98 size_t purgeCounter = ((qsize * frac256) >> 8);
99 if (!purgeCounter && qsize >= 2) {
100 purgeCounter = 1;
101 }
102
103 size_t pc = 0;
104 {
105 TConn* conn;
106 while (purgeCounter-- && cl.Dequeue(&conn)) {
107 conn->SetCached(false);
108 if (conn->IsValid()) {
109 conn->Close();
110 }
111 CachedConn_.Dec();
112 conn->UnRef();
113 ++pc;
114 }
115 }
116 pc += Validate(cl);
117
118 return pc;
119 }
120
121 private:
122 inline TConnList& ConnList(size_t addrId) {

Callers 1

PurgeCacheMethod · 0.45

Calls 9

SetCachedMethod · 0.80
ValidateFunction · 0.50
GetMethod · 0.45
SizeMethod · 0.45
DequeueMethod · 0.45
IsValidMethod · 0.45
CloseMethod · 0.45
DecMethod · 0.45
UnRefMethod · 0.45

Tested by

no test coverage detected