https://github.com/jacob-c-smith/queue
A tested FIFO data structure implementation
https://github.com/jacob-c-smith/queue
c queue tested thread-safe
Last synced: 10 months ago
JSON representation
A tested FIFO data structure implementation
- Host: GitHub
- URL: https://github.com/jacob-c-smith/queue
- Owner: Jacob-C-Smith
- License: mit
- Created: 2022-08-03T22:03:16.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-26T02:31:08.000Z (almost 2 years ago)
- Last Synced: 2025-03-04T22:36:20.967Z (over 1 year ago)
- Topics: c, queue, tested, thread-safe
- Language: C
- Homepage: https://g10.app/status/#abstract_data_i
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# queue
[](https://github.com/Jacob-C-Smith/queue/actions/workflows/cmake.yml)
**Dependencies:**\
[](https://github.com/Jacob-C-Smith/sync/actions/workflows/cmake.yml)
[](https://github.com/Jacob-C-Smith/log/actions/workflows/cmake.yml)
A minimal queue implementation written in C.
> 0 [Try it](#try-it)
>
> 1 [Download](#download)
>
> 2 [Build](#build)
>
> 3 [Example](#example)
>
>> 3.1 [Example output](#example-output)
>
> 4 [Tester](#tester)
>
> 5 [Definitions](#definitions)
>
>> 5.1 [Type definitions](#type-definitions)
>>
>> 5.2 [Function definitions](#function-definitions)
## Try it
[](https://codespaces.new/Jacob-C-Smith/queue?quickstart=1)
Wait for a few moments, then click the play button on the bottom of the window. This will run the example program.
## Download
To download queue, execute the following command
```bash
$ git clone https://github.com/Jacob-C-Smith/queue
```
## Build
To build on UNIX like machines, execute the following commands in the same directory
```bash
$ cd queue
$ cmake .
$ make
```
This will build the example program, the tester program, and dynamic / shared libraries
To build queue for Windows machines, open the base directory in Visual Studio, and build your desired target(s)
## Example
To run the example program, execute this command
```
$ ./queue_example
```
### Example output
```
First!
Second!
Third!
Fourth!
Fifth!
Sixth!
Detected queue underflow!
```
[Source](main.c)
## Tester
To run the tester program, execute this command after building
```
$ ./queue_test
```
[Source](queue_test.c)
## Definitions
### Type definitions
```c
typedef struct queue_s queue;
```
### Function definitions
```c
// Allocaters
DLLEXPORT int queue_create ( queue **pp_queue );
// Constructors
DLLEXPORT int queue_construct ( queue **pp_queue );
DLLEXPORT int queue_from_contents ( queue **pp_queue, void **pp_contents, size_t size );
// Accessors
DLLEXPORT int queue_front ( queue *p_queue , void **pp_value );
DLLEXPORT int queue_rear ( queue *p_queue , void **pp_value );
DLLEXPORT bool queue_empty ( queue *p_queue );
// Mutators
DLLEXPORT int queue_enqueue ( queue *p_queue , void *data );
DLLEXPORT int queue_dequeue ( queue *p_queue , void **pp_value );
// Destructors
DLLEXPORT int queue_destroy ( queue **pp_queue );
```