#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
◆ MSG_SIZE_T
| #define MSG_SIZE_T uint32_t |
◆ READ_MODE
◆ WRITE_MODE
◆ spsc_capacity()
| size_t spsc_capacity |
( |
const spsc_ring * |
ring | ) |
|
Gets the maximum size of the ring.
- Returns
- the maximum size of the ring.
◆ spsc_create_pub()
| int spsc_create_pub |
( |
spsc_ring * |
ring, |
|
|
const char * |
pathname, |
|
|
const size_t |
size |
|
) |
| |
Creates a publisher for a shared memory spsc ring located at the specified path. A new file is created if it doesn't exist.
- Parameters
-
| ring | pointer to a spsc_ring structure |
| pathname | path to the shared memory file |
| size | max size of the ring in bytes |
- Returns
- 0 if successful, otherwise an error code is returned.
◆ spsc_create_sub()
| int spsc_create_sub |
( |
spsc_ring * |
ring, |
|
|
const char * |
pathname, |
|
|
const size_t |
size |
|
) |
| |
Creates a subscriber for a shared memory spsc ring located at the specified path. A new file is created if it doesn't exist.
- Parameters
-
| ring | pointer to a spsc_ring structure |
| pathname | path to the shared memory file |
| size | max size of the ring in bytes |
- Returns
- 0 if successful, otherwise an error code is returned.
◆ spsc_destroy()
◆ spsc_read()
| size_t spsc_read |
( |
spsc_ring * |
ring, |
|
|
void * |
dest, |
|
|
const size_t |
n |
|
) |
| |
Reads the next entry from the ring into the specified location.
- Parameters
-
| ring | pointer to a spsc_ring structure |
| dest | pointer to a location to copy bytes to |
| n | number of bytes to copy, must be less than or equal to the size of dest. |
- Returns
- the number of bytes copied, or 0 if there is nothing left to read.
◆ spsc_size()
Gets an approximate size of the ring. The returned number depends on whether the publishing thread or subscribing thread called the method. The behvaiour is undefined for any other calling thread.
- Parameters
-
- Returns
- an approximate size of the ring.
◆ spsc_write()
Writes an entry into the ring, copying from the specified location.
- Parameters
-
| ring | pointer to a spsc_ring structure |
| src | pointer to a location to copy bytes from |
| n | number of bytes to copy, must be less than or equal to the size of src |
- Returns
- the number of bytes copied, or 0 if the ring is full.