[mammoth] Move port server operations to their own class.

This commit is contained in:
Drew Galbraith 2023-06-26 08:41:44 -07:00
parent 7989c9d616
commit 5fb9fa6ae6
8 changed files with 74 additions and 42 deletions

View file

@ -32,11 +32,11 @@ glcr::ErrorCode HandleDenaliRegistration(z_cap_t endpoint_cap) {
glcr::ErrorOr<YellowstoneServer> YellowstoneServer::Create() {
ASSIGN_OR_RETURN(EndpointServer server, EndpointServer::Create());
ASSIGN_OR_RETURN(Port port, Port::Create());
ASSIGN_OR_RETURN(PortServer port, PortServer::Create());
return YellowstoneServer(server, port);
}
YellowstoneServer::YellowstoneServer(EndpointServer server, Port port)
YellowstoneServer::YellowstoneServer(EndpointServer server, PortServer port)
: server_(server), register_port_(port) {}
Thread YellowstoneServer::RunServer() {
@ -62,7 +62,7 @@ void YellowstoneServer::ServerThread() {
case kYellowstoneGetRegistration: {
dbgln("Yellowstone::GetRegistration");
uint64_t reg_cap;
check(register_port_.Duplicate(&reg_cap));
check(register_port_.CreateClient(&reg_cap));
YellowstoneGetRegistrationResp resp;
check(ZReplyPortSend(reply_port_cap, sizeof(resp), &resp, 1, &reg_cap));
break;