From 39aa16cf47e7b85b936f56a3256c1b547ed1bb68 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 8 Oct 2017 19:34:58 +0200 Subject: Document the timeout interface. --- src/util/timeout.c | 2 +- src/util/timeout.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/util/timeout.c b/src/util/timeout.c index c9608a9..fb3053d 100644 --- a/src/util/timeout.c +++ b/src/util/timeout.c @@ -17,7 +17,7 @@ void timeout_handle(int signum, siginfo_t *siginfo, void *other) { if (timeout_in) siglongjmp(timeout_ptr, 1); } -bool timeout_init(const config_t *cfg) { +bool timeout_init() { struct sigaction new_action; new_action.sa_sigaction = timeout_handle; diff --git a/src/util/timeout.h b/src/util/timeout.h index 7e4d6ce..29b837d 100644 --- a/src/util/timeout.h +++ b/src/util/timeout.h @@ -20,7 +20,14 @@ extern __thread bool timeout_in; extern __thread timer_t timeout_timer; /** - * @brief + * @brief Start a timer that times out after seconds-. + * + * The timer is thread-local. This function is an if-like statement, + * it runs the else part for the duration of the timeout or + * until timeout_stop is called. If that branch times out, then the + * if part is run. The times should be always stopped by + * timeout_stop when the timed interval ends. + * @param seconds how long to run the else branch for */ #define timeout_start(seconds) \ if ((seconds) != 0) { \ @@ -39,7 +46,7 @@ extern __thread timer_t timeout_timer; if ((seconds) != 0 && sigsetjmp(timeout_ptr, 1) == 1) /** - * @brief + * @brief Stop a timer. */ #define timeout_stop() \ { \ @@ -50,10 +57,9 @@ extern __thread timer_t timeout_timer; } /** - * @brief - * @param cfg - * @return + * @brief Initialize the timeout system. + * @return whether the initalization was successful */ -bool timeout_init(const config_t *cfg); +bool timeout_init(); #endif // ECGEN_TIMEOUT_H -- cgit v1.2.3-70-g09d2