MCPcopy Create free account
hub / github.com/ceph/ceph / get_worker

Method get_worker

src/msg/async/Stack.cc:134–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134Worker* NetworkStack::get_worker()
135{
136 ldout(cct, 30) << __func__ << dendl;
137
138 // start with some reasonably large number
139 unsigned min_load = std::numeric_limits<int>::max();
140 Worker* current_best = nullptr;
141
142 pool_spin.lock();
143 // find worker with least references
144 // tempting case is returning on references == 0, but in reality
145 // this will happen so rarely that there's no need for special case.
146 for (Worker* worker : workers) {
147 unsigned worker_load = worker->references.load();
148 if (worker_load < min_load) {
149 current_best = worker;
150 min_load = worker_load;
151 }
152 }
153
154 pool_spin.unlock();
155 ceph_assert(current_best);
156 ++current_best->references;
157 return current_best;
158}
159
160void NetworkStack::stop()
161{

Callers 3

acceptMethod · 0.45
AsyncMessengerMethod · 0.45
create_connectMethod · 0.45

Calls 3

lockMethod · 0.45
loadMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected