Retrieve and remove callback for a request ID (using move semantics)
| 70 | |
| 71 | // Retrieve and remove callback for a request ID (using move semantics) |
| 72 | fl::optional<FetchResponseCallback> takeCallback(u32 request_id) { |
| 73 | fl::unique_lock<fl::mutex> lock(mCallbacksMutex); |
| 74 | auto it = mPendingCallbacks.find(request_id); |
| 75 | if (it != mPendingCallbacks.end()) { |
| 76 | // Move the callback directly from the map entry to avoid double-move |
| 77 | fl::optional<FetchResponseCallback> result = fl::make_optional(fl::move(it->second)); |
| 78 | mPendingCallbacks.erase(it); // Use efficient iterator-based erase |
| 79 | return result; |
| 80 | } |
| 81 | return fl::nullopt; |
| 82 | } |
| 83 | |
| 84 | private: |
| 85 | // Thread-safe storage for pending callbacks using request IDs |
no test coverage detected