mirror of
https://github.com/justinian/jsix.git
synced 2025-12-11 08:54:31 -08:00
Channels were unused, and while they were listed in syscalls.def, they had no syscalls listed in their interface. This change adds them back, and updates them to the curren syscall style.
54 lines
952 B
C++
54 lines
952 B
C++
#include <j6/errors.h>
|
|
#include <j6/types.h>
|
|
#include <util/counted.h>
|
|
|
|
#include "objects/channel.h"
|
|
#include "syscalls/helpers.h"
|
|
|
|
using namespace obj;
|
|
|
|
namespace syscalls {
|
|
|
|
j6_status_t
|
|
channel_create(j6_handle_t *self)
|
|
{
|
|
construct_handle<channel>(self);
|
|
return j6_status_ok;
|
|
}
|
|
|
|
j6_status_t
|
|
channel_send(channel *self, void *data, size_t *data_len)
|
|
{
|
|
if (self->closed())
|
|
return j6_status_closed;
|
|
|
|
const util::buffer buffer {data, *data_len};
|
|
*data_len = self->enqueue(buffer);
|
|
|
|
return j6_status_ok;
|
|
}
|
|
|
|
j6_status_t
|
|
channel_receive(channel *self, void *data, size_t *data_len)
|
|
{
|
|
if (self->closed())
|
|
return j6_status_closed;
|
|
|
|
util::buffer buffer {data, *data_len};
|
|
*data_len = self->dequeue(buffer);
|
|
|
|
return j6_status_ok;
|
|
}
|
|
|
|
j6_status_t
|
|
channel_close(channel *self)
|
|
{
|
|
if (self->closed())
|
|
return j6_status_closed;
|
|
|
|
self->close();
|
|
return j6_status_ok;
|
|
}
|
|
|
|
} // namespace syscalls
|