mirror of
https://github.com/citra-emu/citra-nightly.git
synced 2024-12-24 16:55:36 +00:00
Port "client_port: Make all data members private" from yuzu (#4064)
* client_port: Make all data members private These members don't need to be entirely exposed, we can instead expose an API to operate on them without directly needing to mutate them We can also guard against overflow/API misuse this way as well, given active_sessions is an unsigned value. * make the condition an assert
This commit is contained in:
parent
47025552c7
commit
75927ee462
|
@ -13,8 +13,8 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
ClientPort::ClientPort() {}
|
||||
ClientPort::~ClientPort() {}
|
||||
ClientPort::ClientPort() = default;
|
||||
ClientPort::~ClientPort() = default;
|
||||
|
||||
ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
|
||||
// Note: Threads do not wait for the server endpoint to call
|
||||
|
@ -39,4 +39,10 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
|
|||
return MakeResult(std::get<SharedPtr<ClientSession>>(sessions));
|
||||
}
|
||||
|
||||
void ClientPort::ConnectionClosed() {
|
||||
ASSERT(active_sessions > 0);
|
||||
|
||||
--active_sessions;
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -37,14 +37,20 @@ public:
|
|||
*/
|
||||
ResultVal<SharedPtr<ClientSession>> Connect();
|
||||
|
||||
SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
|
||||
u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
|
||||
u32 active_sessions; ///< Number of currently open sessions to this port
|
||||
std::string name; ///< Name of client port (optional)
|
||||
/**
|
||||
* Signifies that a previously active connection has been closed,
|
||||
* decreasing the total number of active connections to this port.
|
||||
*/
|
||||
void ConnectionClosed();
|
||||
|
||||
private:
|
||||
ClientPort();
|
||||
~ClientPort() override;
|
||||
|
||||
SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
|
||||
u32 max_sessions = 0; ///< Maximum number of simultaneous sessions the port can have
|
||||
u32 active_sessions = 0; ///< Number of currently open sessions to this port
|
||||
std::string name; ///< Name of client port (optional)
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
@ -20,7 +20,7 @@ ServerSession::~ServerSession() {
|
|||
|
||||
// Decrease the port's connection count.
|
||||
if (parent->port)
|
||||
parent->port->active_sessions--;
|
||||
parent->port->ConnectionClosed();
|
||||
|
||||
// TODO(Subv): Wake up all the ClientSession's waiting threads and set
|
||||
// the SendSyncRequest result to 0xC920181A.
|
||||
|
|
Loading…
Reference in a new issue