1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/lib/wsfs/core/message_queue.c
Falk Werner 1c9d1c8420
feat(API wrapper): separates implementation from public API
* moves implementation to impl subdirectory
* adds prefix _impl to implementation symbols
* removes double compilation for shared and static libraries
* fixes include guards
* fixes usage of extern "C"
2019-03-26 15:35:33 +01:00

64 lines
1.3 KiB
C

#include "wsfs/core/message_queue.h"
#include "wsfs/core/message.h"
void wsfs_message_queue_init(
struct wsfs_message_queue * queue)
{
queue->first = NULL;
queue->last = NULL;
}
void wsfs_message_queue_cleanup(
struct wsfs_message_queue * queue)
{
struct wsfs_message * message = queue->first;
while (NULL != message)
{
struct wsfs_message * next = message->next;
wsfs_message_dispose(message);
message = next;
}
wsfs_message_queue_init(queue);
}
bool wsfs_message_queue_empty(
struct wsfs_message_queue * queue)
{
return (NULL == queue->first);
}
void wsfs_message_queue_push(
struct wsfs_message_queue * queue,
struct wsfs_message * message)
{
message->next = NULL;
if (NULL != queue->last)
{
queue->last->next = message;
queue->last = message;
}
else
{
queue->first = message;
queue->last = message;
}
}
struct wsfs_message * wsfs_message_queue_pop(
struct wsfs_message_queue * queue)
{
struct wsfs_message * const result = queue->first;
if (NULL != result)
{
queue->first = queue->first->next;
if (NULL == queue->first)
{
queue->last = NULL;
}
}
return result;
}