mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-08 13:11:49 +00:00
meso: KPort mini skeleton
This commit is contained in:
parent
acf32f841c
commit
173bde2eca
6 changed files with 161 additions and 0 deletions
34
mesosphere/include/mesosphere/processes/KClientPort.hpp
Normal file
34
mesosphere/include/mesosphere/processes/KClientPort.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <mesosphere/core/KSynchronizationObject.hpp>
|
||||
#include <mesosphere/core/util.hpp>
|
||||
#include <mesosphere/core/Result.hpp>
|
||||
#include <mesosphere/interfaces/IClient.hpp>
|
||||
#include <mesosphere/threading/KThread.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
class KPort;
|
||||
class KServerPort;
|
||||
|
||||
class KClientPort final :
|
||||
public KSynchronizationObject,
|
||||
public IClient<KPort, KClientPort, KServerPort> {
|
||||
|
||||
public:
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, ClientPort);
|
||||
|
||||
virtual ~KClientPort();
|
||||
|
||||
virtual bool IsSignaled() const override;
|
||||
|
||||
private:
|
||||
friend class KPort;
|
||||
|
||||
};
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ClientPort);
|
||||
|
||||
}
|
36
mesosphere/include/mesosphere/processes/KPort.hpp
Normal file
36
mesosphere/include/mesosphere/processes/KPort.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <mesosphere/core/util.hpp>
|
||||
#include <mesosphere/core/Result.hpp>
|
||||
#include <mesosphere/interfaces/IClientServerParent.hpp>
|
||||
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
||||
#include <mesosphere/processes/KClientPort.hpp>
|
||||
#include <mesosphere/processes/KServerPort.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
class KPort final :
|
||||
public KAutoObject,
|
||||
public ISetAllocated<KPort>,
|
||||
public IClientServerParent<KPort, KClientPort, KServerPort> {
|
||||
|
||||
public:
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Port);
|
||||
|
||||
virtual ~KPort();
|
||||
|
||||
Result Initialize();
|
||||
|
||||
private:
|
||||
friend class KClientPort;
|
||||
friend class KServerPort;
|
||||
|
||||
bool isClientAlive = false;
|
||||
bool isServerAlive = false;
|
||||
bool isLight = false;
|
||||
};
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Port);
|
||||
|
||||
}
|
31
mesosphere/include/mesosphere/processes/KServerPort.hpp
Normal file
31
mesosphere/include/mesosphere/processes/KServerPort.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <mesosphere/core/KSynchronizationObject.hpp>
|
||||
#include <mesosphere/processes/KLightServerSession.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
class KPort;
|
||||
class KClientPort;
|
||||
|
||||
class KServerPort final :
|
||||
public KSynchronizationObject,
|
||||
public IServer<KPort, KClientPort, KServerPort> {
|
||||
|
||||
public:
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_TRAITS(SynchronizationObject, ServerPort);
|
||||
|
||||
virtual ~KServerPort();
|
||||
|
||||
virtual bool IsSignaled() const override;
|
||||
|
||||
private:
|
||||
friend class KPort;
|
||||
|
||||
};
|
||||
|
||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ServerPort);
|
||||
|
||||
}
|
20
mesosphere/source/processes/KClientPort.cpp
Normal file
20
mesosphere/source/processes/KClientPort.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <mesosphere/processes/KPort.hpp>
|
||||
#include <mesosphere/threading/KScopedCriticalSection.hpp>
|
||||
#include <mesosphere/threading/KThread.hpp>
|
||||
#include <mesosphere/core/KCoreContext.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
KClientPort::~KClientPort()
|
||||
{
|
||||
KScopedCriticalSection critsec{};
|
||||
parent->isClientAlive = false;
|
||||
}
|
||||
|
||||
bool KClientPort::IsSignaled() const
|
||||
{
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
}
|
20
mesosphere/source/processes/KPort.cpp
Normal file
20
mesosphere/source/processes/KPort.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <mesosphere/processes/KPort.hpp>
|
||||
#include <mesosphere/core/KCoreContext.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
KPort::~KPort()
|
||||
{
|
||||
}
|
||||
|
||||
Result KPort::Initialize()
|
||||
{
|
||||
SetClientServerParent();
|
||||
isClientAlive = true;
|
||||
isServerAlive = true;
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
20
mesosphere/source/processes/KServerPort.cpp
Normal file
20
mesosphere/source/processes/KServerPort.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <mesosphere/processes/KPort.hpp>
|
||||
#include <mesosphere/threading/KScopedCriticalSection.hpp>
|
||||
#include <mesosphere/threading/KThread.hpp>
|
||||
#include <mesosphere/core/KCoreContext.hpp>
|
||||
|
||||
namespace mesosphere
|
||||
{
|
||||
|
||||
KServerPort::~KServerPort()
|
||||
{
|
||||
KScopedCriticalSection critsec{};
|
||||
parent->isServerAlive = false;
|
||||
}
|
||||
|
||||
bool KServerPort::IsSignaled() const
|
||||
{
|
||||
return false; // TODO
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue