| 1 | /* |
| 2 | * epoll_queue.h |
| 3 | * |
| 4 | * Copyright (C) 2019 Aerospike, Inc. |
| 5 | * |
| 6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 7 | * license agreements. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU Affero General Public License as published by the Free |
| 11 | * Software Foundation, either version 3 of the License, or (at your option) any |
| 12 | * later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | //========================================================== |
| 26 | // Includes. |
| 27 | // |
| 28 | |
| 29 | #include <stdbool.h> |
| 30 | #include <stdint.h> |
| 31 | |
| 32 | |
| 33 | //========================================================== |
| 34 | // Typedefs & constants. |
| 35 | // |
| 36 | |
| 37 | typedef struct cf_epoll_queue_s { |
| 38 | int32_t event_fd; |
| 39 | |
| 40 | uint32_t read_pos; |
| 41 | uint32_t write_pos; |
| 42 | |
| 43 | uint32_t capacity; |
| 44 | uint32_t ele_sz; |
| 45 | uint8_t* eles; |
| 46 | } cf_epoll_queue; |
| 47 | |
| 48 | |
| 49 | //========================================================== |
| 50 | // Public API. |
| 51 | // |
| 52 | |
| 53 | void cf_epoll_queue_init(cf_epoll_queue* q, uint32_t ele_sz, uint32_t capacity); |
| 54 | void cf_epoll_queue_destroy(cf_epoll_queue* q); |
| 55 | void cf_epoll_queue_push(cf_epoll_queue* q, const void* ele); |
| 56 | bool cf_epoll_queue_pop(cf_epoll_queue* q, void* ele); |
| 57 | |