#pragma once
#include <pthread.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>

#define rb_init(size, type)\
	{(size),\
	0, 0, false, false,\
	type,\
	malloc(sizeof(int)*(size)),\
	PTHREAD_MUTEX_INITIALIZER};

#define rb_free(rb) free(rb.data)

typedef struct rb{
	size_t size;
	size_t w_pos, r_pos;
	bool filled;
	bool error;
	enum {DROP, WAIT} type;
	int* data;
	pthread_mutex_t m;
} rb_t;

void rb_push(rb_t*, int);
int rb_pop(rb_t*);
