/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuRPC.cpp Date: 2022-6-29 Author: Reece ***/ #include #include "AuRPC.hpp" #include "AuRPCClientChannel.hpp" AuSPtr GetRPCProcessor() { return AuAsync::GetSelfIOProcessor(); } bool AuRPC::StartClient(AuAsync::WorkerPId_t worker) { if (worker.second == AuAsync::kThreadIdAny) { return false; } this->pinnedClientThread = worker; return true; } bool AuRPC::StartServer(AuAsync::WorkerPId_t worker) { return this->server.Init(this, worker); } AuSPtr AuRPC::ToServer() { return AuSPtr(AuSharedFromThis(), &this->server); } AuSPtr AuRPC::Connect(const AuString& str) { auto eh = AuMakeShared(this->SharedFromThis()); if (!eh) { return {}; } //if (!AuTryInsert(this->clientChannels, eh)) //{ // return {}; //} if (!eh->Init(str)) { return {}; } return eh; } void AuRPC::SetRecommendedPipeLength(AuUInt32 uLength) { this->optPipeLength = uLength; } AuUInt32 AuRPC::GetLargePacketLength() { auto uLength = this->optPipeLength.value_or(AuHwInfo::GetPageSize() * 16); return uLength / 3; } AuSPtr AuRPCNewInstance() { return AuMakeShared(); }