From 4b1b7cd304e4ec33eabe1690d32ddc9d2f384836 Mon Sep 17 00:00:00 2001 From: Nicolas Dato Date: Tue, 27 Feb 2024 15:10:37 -0300 Subject: Adding itc_flush --- src/itc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/itc.c') diff --git a/src/itc.c b/src/itc.c index 6171d4e..5b6fee9 100644 --- a/src/itc.c +++ b/src/itc.c @@ -87,6 +87,20 @@ int itc_inject(itc *ctx, int timeout_ms, void *element) return 0; } +void itc_flush(itc *ctx) +{ + int i; + + if (ctx == NULL) { + return; + } + + for (i = 0; i < ctx->nslots; i++) { + sem_wait(&ctx->emptied); + sem_post(&ctx->emptied); + } +} + void itc_drop(itc *ctx, itc_free_element free_element) { void *element; -- cgit v1.2.3