| 139 | } |
| 140 | |
| 141 | bool Sock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const |
| 142 | { |
| 143 | // We need a `shared_ptr` holding `this` for `WaitMany()`, but don't want |
| 144 | // `this` to be destroyed when the `shared_ptr` goes out of scope at the |
| 145 | // end of this function. |
| 146 | // Create it with an aliasing shared_ptr that points to `this` without |
| 147 | // owning it. |
| 148 | std::shared_ptr<const Sock> shared{std::shared_ptr<const Sock>{}, this}; |
| 149 | |
| 150 | EventsPerSock events_per_sock{std::make_pair(shared, Events{requested})}; |
| 151 | |
| 152 | if (!WaitMany(timeout, events_per_sock)) { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | if (occurred != nullptr) { |
| 157 | *occurred = events_per_sock.begin()->second.occurred; |
| 158 | } |
| 159 | |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | bool Sock::WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const |
| 164 | { |
no test coverage detected