[mammoth] Move port server operations to their own class.
This commit is contained in:
parent
7989c9d616
commit
5fb9fa6ae6
8 changed files with 74 additions and 42 deletions
|
|
@ -11,17 +11,11 @@ class Port {
|
|||
static glcr::ErrorOr<Port> Create();
|
||||
Port(uint64_t port_cap);
|
||||
|
||||
glcr::ErrorCode RecvCap(uint64_t* num_bytes, char* msg, uint64_t* cap);
|
||||
z_err_t PollForIntCap(uint64_t* msg, uint64_t* cap);
|
||||
|
||||
template <typename T>
|
||||
z_err_t WriteMessage(const T& obj, uint64_t cap);
|
||||
|
||||
glcr::ErrorCode WriteString(glcr::String str, uint64_t cap);
|
||||
|
||||
// FIXME: We can't create error_ors of ints
|
||||
glcr::ErrorCode Duplicate(uint64_t* new_cap);
|
||||
|
||||
private:
|
||||
uint64_t port_cap_;
|
||||
};
|
||||
|
|
|
|||
20
lib/mammoth/include/mammoth/port_server.h
Normal file
20
lib/mammoth/include/mammoth/port_server.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
class PortServer {
|
||||
public:
|
||||
static glcr::ErrorOr<PortServer> Create();
|
||||
static PortServer AdoptCap(z_cap_t cap);
|
||||
|
||||
glcr::ErrorCode CreateClient(z_cap_t* new_port);
|
||||
|
||||
glcr::ErrorCode RecvCap(uint64_t* num_bytes, char* msg, uint64_t* cap);
|
||||
glcr::ErrorCode PollForIntCap(uint64_t* msg, uint64_t* cap);
|
||||
|
||||
private:
|
||||
z_cap_t port_cap_;
|
||||
|
||||
PortServer(z_cap_t cap);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue