[Mammoth] Move ipc calls to separate folder mammoth.
This commit is contained in:
parent
19e394ae7b
commit
ad5b55bf37
19 changed files with 21 additions and 27 deletions
31
lib/mammoth/ipc/port_client.h
Normal file
31
lib/mammoth/ipc/port_client.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
class PortClient {
|
||||
public:
|
||||
PortClient() {}
|
||||
static PortClient AdoptPort(z_cap_t port_cap);
|
||||
|
||||
template <typename T>
|
||||
z_err_t WriteMessage(const T& obj, z_cap_t cap);
|
||||
|
||||
glcr::ErrorCode WriteString(glcr::String str, z_cap_t cap);
|
||||
|
||||
z_cap_t cap() { return port_cap_; }
|
||||
|
||||
bool empty() { return port_cap_ == 0; }
|
||||
|
||||
private:
|
||||
z_cap_t port_cap_ = 0;
|
||||
|
||||
PortClient(z_cap_t port_cap);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
z_err_t PortClient::WriteMessage(const T& obj, z_cap_t cap) {
|
||||
return ZPortSend(port_cap_, sizeof(obj), &obj, 1, &cap);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue