perf: async signal exit ftpsrv and nxlink thread in order to not block. add perf logging for exit.

This commit is contained in:
ITotalJustice
2025-08-11 22:26:28 +01:00
parent 3c33581a08
commit 7835ebc346
7 changed files with 134 additions and 67 deletions

View File

@@ -6,6 +6,7 @@ namespace sphaira::ftpsrv {
bool Init();
void Exit();
void ExitSignal();
using OnInstallStart = std::function<bool(const char* path)>;
using OnInstallWrite = std::function<bool(const void* buf, size_t size)>;

View File

@@ -44,6 +44,9 @@ bool nxlinkInitialize(NxlinkCallback callback);
// signal for the event to close and then join the thread.
void nxlinkExit();
// async the exit, call this first and then call exit later to avoid blocking.
void nxlinkSignalExit();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,24 @@
#pragma once
#include "ui/types.hpp"
#include "log.hpp"
namespace sphaira::utils {
struct ScopedTimestampProfile {
ScopedTimestampProfile(const std::string& name) : m_name{name} {
}
~ScopedTimestampProfile() {
log_write("\t[%s] time taken: %.2fs %.2fms\n", m_name.c_str(), m_ts.GetSecondsD(), m_ts.GetMsD());
}
private:
const std::string m_name;
TimeStamp m_ts{};
};
#define SCOPED_TIMESTAMP(name) sphaira::utils::ScopedTimestampProfile ANONYMOUS_VARIABLE(SCOPE_PROFILE_STATE_){name};
} // namespace sphaira::utils