feynman/src/queue.h

60 lines
1.3 KiB
C

/*
* Feynman -- Wayland compositor for GNU Emacs
*
* Copyright (c) 2022 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FEYNMAN_QUEUE_H
#define FEYNMAN_QUEUE_H
#include <stdbool.h>
#include <stdint.h>
typedef enum event_enum
{
echo = 0,
exit = 1,
} event_type_t;
typedef struct arguments
{
unsigned count;
void **args;
} arguments_t;
typedef struct event
{
unsigned id;
event_type_t event_type;
arguments_t *args;
} event_t;
typedef struct queue
{
unsigned *head;
unsigned *tail;
unsigned size;
event_t *events;
} queue_t;
queue_t *init_queue (unsigned size);
void deinit_queue (queue_t *q);
int enqueue_event (queue_t *q, event_t *event);
event_t *pop_event (queue_t *q);
bool is_queue_empty (queue_t *q);
#endif