meso: KBaseSession

This commit is contained in:
TuxSH 2018-11-11 01:36:15 +01:00 committed by Michael Scire
parent baa34ddab5
commit 86c43331eb
10 changed files with 194 additions and 4 deletions

View file

@ -23,6 +23,9 @@ class KEvent;
class KReadableEvent;
class KWritableEvent;
class KInterruptEvent;
class KBaseSession;
class KBaseClientSession;
class KBaseServerSession;
void intrusive_ptr_add_ref(KProcess *obj);
void intrusive_ptr_release(KProcess *obj);
@ -42,6 +45,15 @@ void intrusive_ptr_release(KWritableEvent *obj);
void intrusive_ptr_add_ref(KInterruptEvent *obj);
void intrusive_ptr_release(KInterruptEvent *obj);
void intrusive_ptr_add_ref(KBaseSession *obj);
void intrusive_ptr_release(KBaseSession *obj);
void intrusive_ptr_add_ref(KBaseClientSession *obj);
void intrusive_ptr_release(KBaseClientSession *obj);
void intrusive_ptr_add_ref(KBaseClientSession *obj);
void intrusive_ptr_release(KBaseServerSession *obj);
class KAutoObject {
public:

View file

@ -21,7 +21,7 @@ class IClient : public IClientTag {
void *operator new(size_t sz) noexcept = delete;
void operator delete(void *ptr) noexcept {}
const SharedPtr<ParentClass>& GetParent() const { return parent; }
ParentClass *GetParent() const { return parent.get(); }
protected:
friend class IClientServerParent<ParentClass, ClientClass, ServerClass>;

View file

@ -21,7 +21,7 @@ class IServer : public IServerTag {
void *operator new(size_t sz) noexcept = delete;
void operator delete(void *ptr) noexcept {};
const SharedPtr<ParentClass> &GetParent() const { return parent; }
ParentClass *GetParent() const { return parent.get(); }
protected:
friend class IClientServerParent<ParentClass, ClientClass, ServerClass>;

View file

@ -0,0 +1,45 @@
#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;
};
inline void intrusive_ptr_add_ref(KBaseClientSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseClientSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
}

View file

@ -0,0 +1,58 @@
#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;
};
inline void intrusive_ptr_add_ref(KBaseServerSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseServerSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
}

View file

@ -0,0 +1,39 @@
#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;
};
inline void intrusive_ptr_add_ref(KBaseSession *obj)
{
intrusive_ptr_add_ref((KAutoObject *)obj);
}
inline void intrusive_ptr_release(KBaseSession *obj)
{
intrusive_ptr_release((KAutoObject *)obj);
}
}

View file

@ -1,7 +1,5 @@
#pragma once
class KProcess;
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/core/KAutoObject.hpp>

View file

@ -0,0 +1,10 @@
#include <mesosphere/processes/KBaseClientSession.hpp>
namespace mesosphere
{
KBaseClientSession::~KBaseClientSession()
{
}
}

View file

@ -0,0 +1,11 @@
#include <mesosphere/processes/KBaseServerSession.hpp>
namespace mesosphere
{
KBaseServerSession::~KBaseServerSession()
{
// Children classes will lock critical section + set client "isRemoteAlive"
}
}

View file

@ -0,0 +1,17 @@
#include <mesosphere/processes/KBaseSession.hpp>
namespace mesosphere
{
KBaseSession::~KBaseSession()
{
}
Result KBaseSession::Initialize()
{
SetClientServerParent();
return ResultSuccess();
}
}