MCPcopy Create free account
hub / github.com/FastLED/FastLED / takeCallback

Method takeCallback

src/platforms/wasm/js_fetch.cpp.hpp:72–82  ·  view source on GitHub ↗

Retrieve and remove callback for a request ID (using move semantics)

Source from the content-addressed store, hash-verified

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
84private:
85 // Thread-safe storage for pending callbacks using request IDs

Callers 2

js_fetch_error_callbackFunction · 0.80

Calls 4

make_optionalFunction · 0.85
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected