MCPcopy Create free account
hub / github.com/SpartanJ/eepp / sendAsyncRequest

Method sendAsyncRequest

src/eepp/network/http.cpp:1431–1473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1429#endif
1430
1431Uint64 Http::sendAsyncRequest( const Http::AsyncResponseCallback& cb, const Http::Request& request,
1432 Time timeout ) {
1433 Uint64 id = Http::AsyncRequest::IdCounter.fetch_add( 1, std::memory_order_relaxed );
1434#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
1435 WGetAsyncRequest* wget = new WGetAsyncRequest();
1436 wget->http = this;
1437 wget->cb = cb;
1438 wget->request = Http::Request( request );
1439 emscripten_async_wget2_data( ( getURI().toString() + request.getUri() ).c_str(),
1440 Request::methodToString( request.getMethod() ).c_str(),
1441 URI( request.getUri() ).getQuery().c_str(), wget, 1,
1442 emscripten_async_wget2_got_data,
1443 emscripten_async_wget2_got_error_data, NULL );
1444 return id;
1445#else
1446 if ( sGlobalThreadPool ) {
1447 sGlobalThreadPool->run( [this, cb, request, timeout, id] {
1448 AsyncRequest asyncRequest( id, this, cb, request, timeout, false );
1449 {
1450 Lock l( mCurRequestsMutex );
1451 mCurRequests[id] = &asyncRequest;
1452 }
1453 asyncRequest.run();
1454 {
1455 Lock l( mCurRequestsMutex );
1456 mCurRequests.erase( id );
1457 }
1458 } );
1459 return id;
1460 }
1461 AsyncRequest* thread = eeNew( AsyncRequest, ( id, this, cb, request, timeout, true ) );
1462 {
1463 Lock l( mCurRequestsMutex );
1464 mCurRequests[id] = thread;
1465 }
1466 thread->launch();
1467 {
1468 Lock l( mThreadsMutex );
1469 mThreads.push_back( thread );
1470 }
1471 return id;
1472#endif
1473}
1474
1475Uint64 Http::downloadAsyncRequest( const Http::AsyncResponseCallback& cb,
1476 const Http::Request& request, IOStream& writeTo, Time timeout ) {

Callers 1

requestAsyncMethod · 0.80

Calls 8

RequestClass · 0.85
c_strMethod · 0.80
getQueryMethod · 0.80
launchMethod · 0.80
push_backMethod · 0.80
toStringMethod · 0.45
runMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected