Skip to content

Commit

Permalink
Add extern "C" guards to queue_.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-yolabs authored and linkmonitor committed Jul 12, 2023
1 parent 09529c9 commit fc628f3
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions eventrouter/internal/queue_.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,37 @@
#include <stdbool.h>
#include <stddef.h>

/// An opaque queue type for ErEvent_t* elements.
typedef void* ErQueue_t;
typedef ErQueue_t ErQueueHandle_t;
#ifdef __cplusplus
extern "C"
{
#endif

/// Allocates a new `ErQueue_t` which can hold at most `a_capacity` elements.
ErQueue_t ErQueueNew(size_t a_capacity);
/// An opaque queue type for ErEvent_t* elements.
typedef void* ErQueue_t;
typedef ErQueue_t ErQueueHandle_t;

/// Frees a `ErQueue_t` previously allocated with `ErQueueNew()`.
void ErQueueFree(ErQueue_t a_queue);
/// Allocates a new `ErQueue_t` that can hold at most `a_capacity` elements.
ErQueue_t ErQueueNew(size_t a_capacity);

/// Blocks until there is a value to read from `a_queue`, then returns it.
ErEvent_t* ErQueuePopFront(ErQueue_t a_queue);
/// Frees a `ErQueue_t` previously allocated with `ErQueueNew()`.
void ErQueueFree(ErQueue_t a_queue);

/// Blocks until there is space to write `a_event` to the queue, then returns.
void ErQueuePushBack(ErQueue_t a_queue, ErEvent_t* a_event);
/// Blocks until there is a value to read from `a_queue`, then returns it.
ErEvent_t* ErQueuePopFront(ErQueue_t a_queue);

/// Returns true if `a_event` was read from `a_queue` within `a_ms`.
bool ErQueueTimedPopFront(ErQueue_t a_queue, ErEvent_t** a_event, int64_t a_ms);
/// Blocks until there is space to write to the queue, then returns.
void ErQueuePushBack(ErQueue_t a_queue, ErEvent_t* a_event);

/// Returns true if `a_event` was written to `a_queue` within `a_ms`.
bool ErQueueTimedPushBack(ErQueue_t a_queue, ErEvent_t* a_event, int64_t a_ms);
/// Returns true if `a_event` was read from `a_queue` within `a_ms`.
bool ErQueueTimedPopFront(ErQueue_t a_queue, ErEvent_t** a_event,
int64_t a_ms);

/// Returns true if `a_event` was written to `a_queue` within `a_ms`.
bool ErQueueTimedPushBack(ErQueue_t a_queue, ErEvent_t* a_event,
int64_t a_ms);

#ifdef __cplusplus
}
#endif

#endif /* EVENTROUTER_QUEUE_H */

0 comments on commit fc628f3

Please sign in to comment.