WorkingSetIPC.h
// WorkingSetIPC.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2020
@import "cxWorkingSetIpc.h"
@import "WsipcSessionProtocolId.h"
@import "Ceda/cxOperation/IWorkingSetMachine.h"
#include "Ceda/cxMessage/TcpMsg.h"
#include <functional>
namespace ceda
{
///////////////////////////////////////////////////////////////////////////////////////////////////
// Reflection of Ceda/cxMessage/TcpMsg.h
$struct+ MessageWriterSettings <<extern>>
{
$ssize_t lowerHysteresisSendSize;
$ssize_t upperHysteresisSendSize;
$ssize_t normalCommitBufferSize;
$ssize_t sendSizeUntilBackToNormalBufferSize;
$ssize_t maxSendSize;
};
$struct+ MessageReaderSettings <<extern>>
{
$ssize_t normalCommitBufferSize;
$ssize_t maxMsgSize;
$ssize_t maxRecvSize;
};
$struct+ TcpSettings <<extern>>
{
$ssize_t sendBufSize;
$ssize_t recBufSize;
$bool enableNagle;
$bool enableKeepAlive;
$int32 keepalivetime;
$int32 keepaliveinterval;
};
$struct+ TcpMsgSessionSettings <<extern>>
{
$TcpSettings tcpSettings;
$MessageReaderSettings msgReaderSettings;
$MessageWriterSettings msgWriterSettings;
};
$enum+ EProtocol <<extern>>
{
TCP_IPv4,
TCP_IPv6
};
$enum+ ESessionFailureType <<extern>>
{
Session,
SessionRead,
SessionWrite
};
$enum+ EEndPointFailureType <<extern>>
{
Open,
Close,
SetOption,
Bind,
Listen,
Accept,
Connect
};
$extern+ ITcpMsgEndPoint;
$extern+ IoContextPool;
$extern+ TcpMsgServer;
$extern+ TcpMsgClient;
// <<extern>> because these functions are defined in the cxMessage library
// todo: cxObject should be reflecting these
$function+ <<extern>> void SetTheDefaultIoContextPoolSize(int32 numThreads);
$function+ <<extern>> IoContextPool* GetTheDefaultIoContextPool();
$function+ <<extern>> IoContextPool* CreateIoContextPool(int32 numThreads);
$function+ void CloseIoContextPool(IoContextPool* pool);
// <<extern>> because this function is defined in the cxMessage library
$function+ <<extern>> TcpMsgServer* CreateTcpMsgServer(
EProtocol protocol,
int32 port,
bool reuse_addr,
ITcpMsgEndPoint& ep,
const TcpMsgSessionSettings& sessionSettings,
IoContextPool* pool);
$function+ void CloseTcpMsgServer(TcpMsgServer* server);
// <<extern>> because this function is defined in the cxMessage library
$function+ <<extern>> TcpMsgClient* CreateTcpMsgClient(
ConstStringZ host,
ConstStringZ service,
ITcpMsgEndPoint& ep,
const TcpMsgSessionSettings& sessionSettings,
IoContextPool* pool);
$function+ void CloseTcpMsgClient(TcpMsgClient* client);
///////////////////////////////////////////////////////////////////////////////////////////////////
@api ITcpMsgSessionHandler* CreateWsipcSession(
ITcpMsgSession& tcpMsgSession, WorkingSetMachine* wsm, const WsipcSessionProtocolId& protocolId,
const WsipcHostInfo& localHostInfo, std::function<void(ESessionFailureType type, std::error_code ec)> errorCallback);
/*
Create an end point which can be plugged into the TcpMsg messaging framework,
that allows for synchronisation of the WorkingSetMachine with other client or server instances
by sending and receiving working set deltas and Rod objects on the given WorkingSetMachine.
The protocol begins with an exchange of siteids and vector times.
It is expected that the peer will call the same function in order to set up their side of
the connection.
*/
$function+ ITcpMsgEndPoint* CreateWsipcEndPoint(WorkingSetMachine* wsm, const WsipcSessionProtocolId& protocolId, const WsipcHostInfo& localHostInfo);
} // namespace ceda