libguac 1.6.0
 
Loading...
Searching...
No Matches
fifo.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef GUAC_FIFO_H
21#define GUAC_FIFO_H
22
23#include "fifo-constants.h"
24#include "fifo-types.h"
25#include "flag.h"
26
27#include <stddef.h>
28#include <sys/types.h>
29
37
44
45struct guac_fifo {
46
54
58 size_t max_items;
59
64 size_t item_size;
65
71 size_t head;
72
76 size_t item_count;
77
83 ssize_t items_offset;
84
85};
86
109void guac_fifo_init(guac_fifo* fifo, void* items,
110 size_t max_items, size_t item_size);
111
126
143
155
171
184
201int guac_fifo_enqueue(guac_fifo* fifo, const void* item);
202
220int guac_fifo_enqueue_and_lock(guac_fifo* fifo, const void* item);
221
238int guac_fifo_dequeue(guac_fifo* fifo, void* item);
239
258
281 void* item, int msec_timeout);
282
307 void* item, int msec_timeout);
308
312
313#endif
314
Provides constants for the abstract FIFO implementation (guac_fifo).
Provides type definitions for the abstract FIFO implementation (guac_fifo).
void guac_fifo_init(guac_fifo *fifo, void *items, size_t max_items, size_t item_size)
Initializes the given guac_fifo such that it may be safely included in shared memory and accessed by ...
int guac_fifo_timed_dequeue(guac_fifo *fifo, void *item, int msec_timeout)
Removes the oldest (first) item from the FIFO, storing a copy of that item within the provided buffer...
void guac_fifo_lock(guac_fifo *fifo)
Acquires exclusive access to this guac_fifo.
int guac_fifo_enqueue_and_lock(guac_fifo *fifo, const void *item)
Atomically adds a copy of the given item to the end of the given FIFO, signals any waiting threads th...
int guac_fifo_timed_dequeue_and_lock(guac_fifo *fifo, void *item, int msec_timeout)
Atomically removes the oldest (first) item from the FIFO, storing a copy of that item within the prov...
void guac_fifo_invalidate(guac_fifo *fifo)
Marks the given FIFO as invalid, preventing any further additions or removals from the FIFO.
void guac_fifo_unlock(guac_fifo *fifo)
Relinquishes exclusive access to this guac_fifo.
void guac_fifo_destroy(guac_fifo *fifo)
Releases all underlying resources used by the given guac_fifo, such as pthread mutexes and conditions...
int guac_fifo_dequeue_and_lock(guac_fifo *fifo, void *item)
Atomically removes the oldest (first) item from the FIFO, storing a copy of that item within the prov...
int guac_fifo_enqueue(guac_fifo *fifo, const void *item)
Adds a copy of the given item to the end of the given FIFO, and signals any waiting threads that the ...
int guac_fifo_is_valid(guac_fifo *fifo)
Returns whether the given FIFO is still valid.
int guac_fifo_dequeue(guac_fifo *fifo, void *item)
Removes the oldest (first) item from the FIFO, storing a copy of that item within the provided buffer...
Generic base structure for a FIFO of arbitrary events.
Definition fifo.h:45
size_t item_count
The current number of items stored within this FIFO.
Definition fifo.h:76
guac_flag state
The current state of this FIFO.
Definition fifo.h:53
size_t max_items
The maximum number of items that may be stored in this FIFO.
Definition fifo.h:58
size_t head
The index of the first item within this FIFO.
Definition fifo.h:71
size_t item_size
The size of each individual item, in bytes.
Definition fifo.h:64
ssize_t items_offset
The offset of the first byte of the implementation-specific array of items within this FIFO,...
Definition fifo.h:83
Generic integer flag intended for signalling of arbitrary events between processes.
Definition flag.h:27