[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
|
|
@ -5,39 +5,3 @@
|
|||
glcr::RefPtr<Endpoint> Endpoint::Create() {
|
||||
return glcr::AdoptPtr(new Endpoint);
|
||||
}
|
||||
|
||||
glcr::ErrorCode Endpoint::Write(uint64_t num_bytes, const void* data,
|
||||
z_cap_t reply_port_cap) {
|
||||
MutexHolder h(mutex_);
|
||||
RET_ERR(message_queue_.PushBack(num_bytes, data, 1, &reply_port_cap));
|
||||
|
||||
if (blocked_threads_.size() > 0) {
|
||||
auto thread = blocked_threads_.PopFront();
|
||||
thread->SetState(Thread::RUNNABLE);
|
||||
gScheduler->Enqueue(thread);
|
||||
}
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
glcr::ErrorCode Endpoint::Read(uint64_t* num_bytes, void* data,
|
||||
z_cap_t* reply_port_cap) {
|
||||
mutex_.Lock();
|
||||
while (message_queue_.empty()) {
|
||||
auto thread = gScheduler->CurrentThread();
|
||||
thread->SetState(Thread::BLOCKED);
|
||||
mutex_.Unlock();
|
||||
gScheduler->Yield();
|
||||
mutex_.Lock();
|
||||
}
|
||||
mutex_.Unlock();
|
||||
|
||||
MutexHolder h(mutex_);
|
||||
|
||||
uint64_t num_caps = 1;
|
||||
RET_ERR(message_queue_.PopFront(num_bytes, data, &num_caps, reply_port_cap));
|
||||
|
||||
if (num_caps != 1) {
|
||||
return glcr::INTERNAL;
|
||||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue