[mammoth] Update EndpointServer to have move-only semantics.
This commit is contained in:
parent
16c30d12fb
commit
2e89aee5a3
8 changed files with 40 additions and 29 deletions
|
|
@ -28,11 +28,12 @@ uint64_t main(uint64_t init_port_cap) {
|
|||
auto resp_cap = resp_cap_or.value();
|
||||
PortClient notify = PortClient::AdoptPort(resp_cap.second());
|
||||
|
||||
ASSIGN_OR_RETURN(EndpointServer endpoint, EndpointServer::Create());
|
||||
ASSIGN_OR_RETURN(EndpointClient client, endpoint.CreateClient());
|
||||
ASSIGN_OR_RETURN(glcr::UniquePtr<EndpointServer> endpoint,
|
||||
EndpointServer::Create());
|
||||
ASSIGN_OR_RETURN(EndpointClient client, endpoint->CreateClient());
|
||||
notify.WriteMessage("denali", client.GetCap());
|
||||
|
||||
DenaliServer server(endpoint, driver);
|
||||
DenaliServer server(glcr::Move(endpoint), driver);
|
||||
RET_ERR(server.RunServer());
|
||||
// FIXME: Add thread join.
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "denali_server.h"
|
||||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <zcall.h>
|
||||
|
|
@ -12,8 +13,9 @@ void HandleResponse(z_cap_t reply_port, uint64_t lba, uint64_t size,
|
|||
}
|
||||
} // namespace
|
||||
|
||||
DenaliServer::DenaliServer(EndpointServer server, AhciDriver& driver)
|
||||
: server_(server), driver_(driver) {
|
||||
DenaliServer::DenaliServer(glcr::UniquePtr<EndpointServer> server,
|
||||
AhciDriver& driver)
|
||||
: server_(glcr::Move(server)), driver_(driver) {
|
||||
gServer = this;
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ glcr::ErrorCode DenaliServer::RunServer() {
|
|||
while (true) {
|
||||
uint64_t buff_size = kBuffSize;
|
||||
z_cap_t reply_port;
|
||||
RET_ERR(server_.Recieve(&buff_size, read_buffer_, &reply_port));
|
||||
RET_ERR(server_->Recieve(&buff_size, read_buffer_, &reply_port));
|
||||
if (buff_size < sizeof(uint64_t)) {
|
||||
dbgln("Skipping invalid message");
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class DenaliServer {
|
||||
public:
|
||||
DenaliServer(EndpointServer server, AhciDriver& driver);
|
||||
DenaliServer(glcr::UniquePtr<EndpointServer> server, AhciDriver& driver);
|
||||
|
||||
glcr::ErrorCode RunServer();
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class DenaliServer {
|
|||
|
||||
private:
|
||||
static const uint64_t kBuffSize = 1024;
|
||||
EndpointServer server_;
|
||||
glcr::UniquePtr<EndpointServer> server_;
|
||||
uint8_t read_buffer_[kBuffSize];
|
||||
|
||||
AhciDriver& driver_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue