summaryrefslogtreecommitdiffstats
path: root/proc/ipc.h
blob: 4a3dce3fdebe8a87b6bef6c4d544b90e91efc458 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _JOVE_PROC_IPC_H
#define _JOVE_PROC_IPC_H 1

#include "hal/obj.h"
#include "api/process.h"
#include <stdatomic.h>
#include <stdbool.h>

struct port
{
    pid_t owner;

    struct port *send_target;
    jove_obj_t send;

    struct port *recv_target;
    jove_obj_t recv;
};

pid_t port_get_owner(struct port *port);

struct port *port_get_send_target(struct port *port);
struct port *port_get_recv_target(struct port *port);
void port_set_recv_target(struct port *port, struct port *target);

bool port_poll_send(struct port *port);
bool port_poll_recv(struct port *port);

int port_take_send(struct port *port, jove_owned_obj_t *dest_obj);
struct port *port_take_recv(struct port *port, jove_owned_obj_t *dest_obj);

int port_send(struct port *source, struct port *target, jove_owned_obj_t *sent_obj);
int port_recv(struct port *source, struct port *target);

#endif