Files
ppsspp/Common/Net/HTTPNaettRequest.h
T
libretroadmin f1208a7a5a Make threading lock-free
The core and the headless tools no longer use mutexes, condition variables,
spinlocks, std::atomic, std::thread or volatile flags. Threads hand off through
libretro-common's retro_atomic and rthreads plus a few small pieces on top of
them in Common/Thread: Thread, MpscQueue, EventCounter, ParkingLot waits and
ReaderGate. Every wait blocks until it's woken; nothing polls on a timer.

State that only one thread touches just loses its lock. The PSP filesystem,
sceIo and the savedata dialog now belong to the emulation thread: async reads
and writes run when they're queued and complete later in emulated time, and
the IO and savedata threads are gone. The friend finder only talks to the
adhoc server and hands what it gets to the emulation thread. GPU init always
runs on the thread that starts the game.

The Vulkan render and compile queues, pipeline and render pass caches, delete
list and SPIR-V cache, the GL render queue, the software renderer's jit caches,
the file loader caches, the web debugger, UPnP, input, savestates, logging and
the GE debugger all hand off through queues and atomics. The IR jit's spinning
profiler thread goes.

A CPU thread with nothing to run now sleeps until work is queued instead of
spinning. Headless with --debugger waits for a client while stopped, and ends
the run once every client that connected has left. Web server shutdown keeps
servicing the CPU queue until the server has finished.
2026-10-09 04:56:16 +02:00

56 lines
1.5 KiB
C++

#pragma once
#include <memory>
#include <string_view>
#include "Common/Net/HTTPRequest.h"
#ifndef HTTPS_NOT_AVAILABLE
#include "ext/naett-lib/naett.h"
namespace http {
struct NaettBodySink;
void HTTPSShutdown();
// Really an asynchronous request.
class HTTPSRequest : public Request {
public:
HTTPSRequest(RequestMethod method, std::string_view url, std::string_view postData, std::string_view postMime, const Path &outfile, RequestFlags flags = RequestFlags::ProgressBar | RequestFlags::ProgressBarDelayed, std::string_view name = "");
~HTTPSRequest();
void Start() override;
void Join() override;
// Also acts as a Poll.
bool Done() override;
bool Failed() const override { return failed_; }
// Cancelling has to reach naett, or it only changes the code we report once the transfer ends
// on its own. See the .cpp.
void Cancel() override;
private:
static int WriteBodyThunk(const void *source, int bytes, void *userData);
std::string postData_;
std::string postMime_;
bool completed_ = false;
bool failed_ = false;
// Where the response body lands. Deliberately not part of this object: naett writes into it
// from its own transfer thread, and that can outlive us if we're torn down before the request
// finishes, so ownership has to be able to move elsewhere. See NaettBodySink in the .cpp.
std::unique_ptr<NaettBodySink> sink_;
// Naett state
naettReq *req_ = nullptr;
naettRes *res_ = nullptr;
};
} // namespace http
#endif // HTTPS_NOT_AVAILABLE