#ifndef _KERNEL_PROC_MAIL_H
#define _KERNEL_PROC_MAIL_H

#include <libk/list.h>
#include <libk/ringbuffer.h>
#include <libk/std.h>
#include <proc/suspension_q.h>

#define PROC_MAIL_MAX 1024

struct proc;
struct proc_resource;
struct cpu;
struct reschedule_ctx;

struct mail_packet {
  void* packet_buffer;
  size_t packet_size;
};

struct proc_mail {
  struct proc_resource* resource;

  struct proc_suspension_q send_sq;
  struct proc_suspension_q recv_sq;
  struct ringbuffer ringbuffer;
};

void proc_cleanup_resource_mail (struct proc_resource* resource, struct reschedule_ctx* rctx);

void proc_mail_send (struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
                     void* data, size_t data_size);

void proc_mail_receive (struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
                        void* recv_buffer, size_t recv_size);

#endif // _KERNEL_PROC_MAIL_H
