mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 15:30:29 +02:00
Socket waits now block in select() on the socket plus a wake or cancel socket (Common/Net/Cancel), so a stop or cancel ends them at once. - HTTP: cancel flags become net::CancelToken; Connect waits once on all addresses, receives wait instead of spinning, no DNS retry sleep. - Adhoc: the friend finder and adhoc server block on their sockets with a wake socket and a deadline; matching runs on a CoreTiming tick instead of two threads (savestate section bumped). - sceNetInet select/poll check without blocking and park the HLE thread, re-checked from a CoreTiming event until ready or the emulated timeout. - Vendor the aemu_postoffice client (was a submodule) with no sleeps: waits on the socket, close via shutdown and an eventcount, cancelable connects, and lock-free session slot claims. - PortManager waits without a timeout; PSP_InitWait replaces the headless boot poll. - TimeUtil: sleep_us/sleep_ms only outside the core; sleep_precise, sleep_random, yield and the Windows timer period are gone. - Unit test for the socket waits.
36 lines
860 B
C++
36 lines
860 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
|
|
#include "Common/Buffer.h"
|
|
#include "Common/Net/Cancel.h"
|
|
|
|
namespace net {
|
|
|
|
class RequestProgress {
|
|
public:
|
|
explicit RequestProgress(const CancelToken *c) : cancel(c) {}
|
|
|
|
void Update(int64_t downloaded, int64_t totalBytes, bool done);
|
|
|
|
float progress = 0.0f;
|
|
float kBps = 0.0f;
|
|
const CancelToken *cancel = nullptr;
|
|
std::function<void(int64_t, int64_t, bool)> callback;
|
|
};
|
|
|
|
class Buffer : public ::Buffer {
|
|
public:
|
|
bool FlushSocket(uintptr_t sock, double timeout, const CancelToken *cancel = nullptr);
|
|
|
|
// If you know the size of the file to read, pass it in knownSize, for best performance and for progress reporting.
|
|
bool ReadAllWithProgress(int fd, int knownSize, RequestProgress *progress);
|
|
|
|
// < 0: error
|
|
// >= 0: number of bytes read
|
|
int Read(int fd, size_t sz);
|
|
};
|
|
|
|
} // namespace net
|