mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-03 11:11:14 +00:00
meso: add KLightSession skeleton, remove KBaseSession
This commit is contained in:
parent
eb7e4153d1
commit
9c8f818c29
14 changed files with 165 additions and 159 deletions
|
@ -32,9 +32,9 @@ MESOSPHERE_AUTO_OBJECT_FW_DECL(Event);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(ReadableEvent);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(ReadableEvent);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(WritableEvent);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(WritableEvent);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(InterruptEvent);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(InterruptEvent);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseSession);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightSession);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseClientSession);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightClientSession);
|
||||||
MESOSPHERE_AUTO_OBJECT_FW_DECL(BaseServerSession);
|
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightServerSession);
|
||||||
|
|
||||||
class KAutoObject {
|
class KAutoObject {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -31,6 +31,7 @@ class KResourceLimit final :
|
||||||
case KAutoObject::TypeId::Event: return Category::Events;
|
case KAutoObject::TypeId::Event: return Category::Events;
|
||||||
case KAutoObject::TypeId::TransferMemory: return Category::TransferMemories;
|
case KAutoObject::TypeId::TransferMemory: return Category::TransferMemories;
|
||||||
case KAutoObject::TypeId::Session: return Category::Sessions;
|
case KAutoObject::TypeId::Session: return Category::Sessions;
|
||||||
|
case KAutoObject::TypeId::LightSession: return Category::Sessions;
|
||||||
default: return Category::Max;
|
default: return Category::Max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <mesosphere/core/util.hpp>
|
|
||||||
#include <mesosphere/core/Result.hpp>
|
|
||||||
#include <mesosphere/core/KAutoObject.hpp>
|
|
||||||
#include <mesosphere/interfaces/IClient.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
class KBaseServerSession;
|
|
||||||
class KBaseSession;
|
|
||||||
class KClientPort;
|
|
||||||
class KBaseClientSession : public KAutoObject, public IClient<KBaseSession, KBaseClientSession, KBaseServerSession> {
|
|
||||||
// Note: hidden from the KAutoObject hierarchy
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~KBaseClientSession();
|
|
||||||
|
|
||||||
// For covariant types
|
|
||||||
virtual KBaseSession *GetParentSession() const { return parent.get(); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class KBaseSession;
|
|
||||||
friend class KBaseServerSession;
|
|
||||||
|
|
||||||
KBaseClientSession() = default;
|
|
||||||
|
|
||||||
bool isRemoteActive = false;
|
|
||||||
KClientPort *parentPort = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseClientSession);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <mesosphere/core/util.hpp>
|
|
||||||
#include <mesosphere/core/Result.hpp>
|
|
||||||
#include <mesosphere/core/KSynchronizationObject.hpp>
|
|
||||||
#include <mesosphere/interfaces/IServer.hpp>
|
|
||||||
|
|
||||||
#include <boost/intrusive/list.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
class KBaseClientSession;
|
|
||||||
class KBaseSession;
|
|
||||||
class KClientPort;
|
|
||||||
|
|
||||||
struct ServerSessionListTag;
|
|
||||||
using ServerSessionListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ServerSessionListTag> >;
|
|
||||||
|
|
||||||
class KBaseServerSession :
|
|
||||||
public KSynchronizationObject,
|
|
||||||
public IServer<KBaseSession, KBaseClientSession, KBaseServerSession>,
|
|
||||||
public ServerSessionListBaseHook {
|
|
||||||
// Note: hidden from the KAutoObject hierarchy
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
using List = typename boost::intrusive::make_list<
|
|
||||||
KBaseServerSession,
|
|
||||||
boost::intrusive::base_hook<ServerSessionListBaseHook>,
|
|
||||||
boost::intrusive::constant_time_size<false>
|
|
||||||
>::type;
|
|
||||||
|
|
||||||
virtual ~KBaseServerSession();
|
|
||||||
|
|
||||||
// For covariant types
|
|
||||||
virtual KBaseSession *GetParentSession() const { return parent.get(); }
|
|
||||||
|
|
||||||
virtual bool IsSignaled() const override { return false; } // hacky; to make it non-abstract
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class KBaseSession;
|
|
||||||
|
|
||||||
KBaseServerSession() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseServerSession);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <mesosphere/core/util.hpp>
|
|
||||||
#include <mesosphere/core/Result.hpp>
|
|
||||||
#include <mesosphere/processes/KBaseClientSession.hpp>
|
|
||||||
#include <mesosphere/processes/KBaseServerSession.hpp>
|
|
||||||
#include <mesosphere/interfaces/IClientServerParent.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
class KBaseSession : public KAutoObject, public IClientServerParent<KBaseSession, KBaseClientSession, KBaseServerSession> {
|
|
||||||
// Note: hidden from the KAutoObject hierarchy
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~KBaseSession();
|
|
||||||
|
|
||||||
// For covariant types:
|
|
||||||
virtual KBaseClientSession *GetClientSession() { return &client; }
|
|
||||||
virtual KBaseServerSession *GetServerSession() { return &server; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
Result Initialize();
|
|
||||||
KBaseSession() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(BaseSession);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mesosphere/core/util.hpp>
|
||||||
|
#include <mesosphere/core/Result.hpp>
|
||||||
|
#include <mesosphere/core/KAutoObject.hpp>
|
||||||
|
#include <mesosphere/interfaces/IClient.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
class KLightSession;
|
||||||
|
class KClientPort;
|
||||||
|
|
||||||
|
class KLightClientSession final : public KAutoObject, public IClient<KLightSession, KLightClientSession, KLightServerSession> {
|
||||||
|
public:
|
||||||
|
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, LightClientSession);
|
||||||
|
|
||||||
|
virtual ~KLightClientSession();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class KLightSession;
|
||||||
|
|
||||||
|
KClientPort *parentPort = nullptr;
|
||||||
|
bool isRemoteActive = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(LightClientSession);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mesosphere/core/util.hpp>
|
||||||
|
#include <mesosphere/core/Result.hpp>
|
||||||
|
#include <mesosphere/core/KSynchronizationObject.hpp>
|
||||||
|
#include <mesosphere/interfaces/IServer.hpp>
|
||||||
|
#include <mesosphere/threading/KThread.hpp>
|
||||||
|
|
||||||
|
#include <boost/intrusive/list.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
class KLightClientSession;
|
||||||
|
class KLightSession;
|
||||||
|
class KClientPort;
|
||||||
|
|
||||||
|
struct LightServerSessionListTag;
|
||||||
|
using LightServerSessionListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<LightServerSessionListTag> >;
|
||||||
|
|
||||||
|
class KLightServerSession final :
|
||||||
|
public KSynchronizationObject,
|
||||||
|
public IServer<KLightSession, KLightClientSession, KLightServerSession>,
|
||||||
|
public LightServerSessionListBaseHook {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, LightServerSession);
|
||||||
|
|
||||||
|
using List = typename boost::intrusive::make_list<
|
||||||
|
KLightServerSession,
|
||||||
|
boost::intrusive::base_hook<LightServerSessionListBaseHook>,
|
||||||
|
boost::intrusive::constant_time_size<false>
|
||||||
|
>::type;
|
||||||
|
|
||||||
|
virtual ~KLightServerSession();
|
||||||
|
|
||||||
|
virtual bool IsSignaled() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend class KLightSession;
|
||||||
|
|
||||||
|
KThread::WaitList senderThreads{}, receiverThreads{};
|
||||||
|
SharedPtr<KThread> currentSender{}, currentReceiver{};
|
||||||
|
bool isRemoteActive = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(LightServerSession);
|
||||||
|
|
||||||
|
}
|
31
mesosphere/include/mesosphere/processes/KLightSession.hpp
Normal file
31
mesosphere/include/mesosphere/processes/KLightSession.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mesosphere/core/util.hpp>
|
||||||
|
#include <mesosphere/core/Result.hpp>
|
||||||
|
#include <mesosphere/interfaces/IClientServerParent.hpp>
|
||||||
|
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
||||||
|
#include <mesosphere/interfaces/ILimitedResource.hpp>
|
||||||
|
#include <mesosphere/processes/KLightClientSession.hpp>
|
||||||
|
#include <mesosphere/processes/KLightServerSession.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
class KLightSession final :
|
||||||
|
public KAutoObject,
|
||||||
|
public ISetAllocated<KLightSession>,
|
||||||
|
public ILimitedResource<KLightSession>,
|
||||||
|
public IClientServerParent<KLightSession, KLightClientSession, KLightServerSession> {
|
||||||
|
|
||||||
|
public:
|
||||||
|
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, LightSession);
|
||||||
|
MESOSPHERE_LIMITED_RESOURCE_TRAITS(10s);
|
||||||
|
|
||||||
|
virtual ~KLightSession();
|
||||||
|
|
||||||
|
Result Initialize();
|
||||||
|
};
|
||||||
|
|
||||||
|
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(LightSession);
|
||||||
|
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
#include <mesosphere/processes/KBaseClientSession.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
KBaseClientSession::~KBaseClientSession()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
#include <mesosphere/processes/KBaseServerSession.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
KBaseServerSession::~KBaseServerSession()
|
|
||||||
{
|
|
||||||
// Children classes will lock critical section + set client "isRemoteAlive"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
#include <mesosphere/processes/KBaseSession.hpp>
|
|
||||||
|
|
||||||
namespace mesosphere
|
|
||||||
{
|
|
||||||
|
|
||||||
KBaseSession::~KBaseSession()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Result KBaseSession::Initialize()
|
|
||||||
{
|
|
||||||
SetClientServerParent();
|
|
||||||
|
|
||||||
return ResultSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
12
mesosphere/source/processes/KLightClientSession.cpp
Normal file
12
mesosphere/source/processes/KLightClientSession.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <mesosphere/processes/KLightClientSession.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
KLightClientSession::~KLightClientSession()
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
17
mesosphere/source/processes/KLightServerSession.cpp
Normal file
17
mesosphere/source/processes/KLightServerSession.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include <mesosphere/processes/KLightServerSession.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
KLightServerSession::~KLightServerSession()
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KLightServerSession::IsSignaled() const
|
||||||
|
{
|
||||||
|
return false; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
21
mesosphere/source/processes/KLightSession.cpp
Normal file
21
mesosphere/source/processes/KLightSession.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include <mesosphere/processes/KLightSession.hpp>
|
||||||
|
#include <mesosphere/core/KCoreContext.hpp>
|
||||||
|
|
||||||
|
namespace mesosphere
|
||||||
|
{
|
||||||
|
|
||||||
|
KLightSession::~KLightSession()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Result KLightSession::Initialize()
|
||||||
|
{
|
||||||
|
SetClientServerParent();
|
||||||
|
client.isRemoteActive = true;
|
||||||
|
server.isRemoteActive = true;
|
||||||
|
|
||||||
|
SetResourceOwner(KCoreContext::GetCurrentInstance().GetCurrentProcess());
|
||||||
|
return ResultSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue