[zion] Move IPC objects to share code
This commit is contained in:
parent
58df2c0ed2
commit
9dd457391c
14 changed files with 125 additions and 196 deletions
33
zion/object/ipc_object.h
Normal file
33
zion/object/ipc_object.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/intrusive_list.h>
|
||||
#include <glacier/status/error.h>
|
||||
|
||||
#include "include/ztypes.h"
|
||||
#include "lib/message_queue.h"
|
||||
#include "lib/mutex.h"
|
||||
#include "object/kernel_object.h"
|
||||
|
||||
class IpcObject : public KernelObject {
|
||||
public:
|
||||
IpcObject(){};
|
||||
virtual ~IpcObject() {}
|
||||
|
||||
virtual glcr::ErrorCode Send(uint64_t num_bytes, const void* bytes,
|
||||
uint64_t num_caps, const z_cap_t* caps) final;
|
||||
virtual glcr::ErrorCode Recv(uint64_t* num_bytes, void* bytes,
|
||||
uint64_t* num_caps, z_cap_t* caps) final;
|
||||
|
||||
bool HasMessages() {
|
||||
MutexHolder h(mutex_);
|
||||
return !GetRecvMessageQueue().empty();
|
||||
}
|
||||
|
||||
virtual MessageQueue& GetSendMessageQueue() = 0;
|
||||
virtual MessageQueue& GetRecvMessageQueue() = 0;
|
||||
|
||||
protected:
|
||||
// FIXME: move locking and blocked threads to the message queue itself.
|
||||
Mutex mutex_{"ipc"};
|
||||
glcr::IntrusiveList<Thread> blocked_threads_;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue