MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / RunCallbackOnMain

Method RunCallbackOnMain

src/NodeRTLib/ProjectFiles/node-async.h:209–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207 }
208
209 static void __cdecl RunCallbackOnMain(
210 uv_async_t* async,
211 std::function<void(InvokeCallbackDelegate invokeCallback)> func) {
212 TokenData* Token = static_cast<TokenData*>(async->data);
213
214 InvokeCallbackDelegate invokeCallback = [Token](int argc,
215 Handle<Value>* argv) {
216 if (!Token->callbackData.IsEmpty()) {
217 MakeCallback(New(Token->callbackData),
218 New<String>("callback").ToLocalChecked(), argc, argv);
219 }
220 };
221
222 std::function<void()> wrapper = [func, invokeCallback]() {
223 HandleScope scope;
224 func(invokeCallback);
225 };
226
227 RunOnMain(async, wrapper);
228 }
229
230 // defers execution of the provided function by creating an idler
231 // that means, the function will be invoked once the event loop has delivered

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected