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/adapter/impl/time/timeout_manager.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

85 lines
1.8 KiB
C

#include "wsfs/adapter/impl/time/timeout_manager_intern.h"
#include <stddef.h>
#include "wsfs/adapter/impl/time/timer_intern.h"
#include "wsfs/adapter/impl/time/timepoint.h"
void wsfs_impl_timeout_manager_init(
struct wsfs_impl_timeout_manager * manager)
{
manager->timers = NULL;
}
void wsfs_impl_timeout_manager_cleanup(
struct wsfs_impl_timeout_manager * manager)
{
struct wsfs_impl_timer * timer = manager->timers;
while (NULL != timer)
{
struct wsfs_impl_timer * next = timer->next;
wsfs_impl_timer_trigger(timer);
timer = next;
}
manager->timers = NULL;
}
void wsfs_impl_timeout_manager_check(
struct wsfs_impl_timeout_manager * manager)
{
struct wsfs_impl_timer * timer = manager->timers;
while (NULL != timer)
{
struct wsfs_impl_timer * next = timer->next;
if (wsfs_impl_timer_is_timeout(timer))
{
wsfs_impl_timeout_manager_removetimer(manager, timer);
wsfs_impl_timer_trigger(timer);
}
timer = next;
}
}
void wsfs_impl_timeout_manager_addtimer(
struct wsfs_impl_timeout_manager * manager,
struct wsfs_impl_timer * timer)
{
if (NULL != manager->timers)
{
manager->timers->prev = timer;
}
timer->next = manager->timers;
timer->prev = NULL;
manager->timers = timer;
}
void wsfs_impl_timeout_manager_removetimer(
struct wsfs_impl_timeout_manager * manager,
struct wsfs_impl_timer * timer)
{
struct wsfs_impl_timer * prev = timer->prev;
struct wsfs_impl_timer * next = timer->next;
if (NULL != prev)
{
prev->next = next;
}
if (NULL != next)
{
next->prev = prev;
}
if (manager->timers == timer)
{
manager->timers = next;
}
}