| 81 | } |
| 82 | |
| 83 | inline void Loop(size_t threads) { |
| 84 | Y_ENSURE(!HasLoop_ || *HasLoop_); |
| 85 | HasLoop_ = true; |
| 86 | |
| 87 | TIntrusivePtr<TServices> self(this); |
| 88 | IRequesterRef rr = MultiRequester(ListenAddrs(), this); |
| 89 | TFunc func(this); |
| 90 | |
| 91 | typedef TAutoPtr<IThreadFactory::IThread> IThreadRef; |
| 92 | TVector<IThreadRef> thrs; |
| 93 | |
| 94 | for (size_t i = 1; i < threads; ++i) { |
| 95 | thrs.push_back(SystemThreadFactory()->Run(&func)); |
| 96 | } |
| 97 | |
| 98 | func.Execute(); |
| 99 | |
| 100 | for (size_t i = 0; i < thrs.size(); ++i) { |
| 101 | thrs[i]->Join(); |
| 102 | } |
| 103 | RQ_->Clear(); |
| 104 | } |
| 105 | |
| 106 | inline void ForkLoop(size_t threads) { |
| 107 | Y_ENSURE(!HasLoop_ || *HasLoop_); |