diff options
author | Nicolas Dato <nicolas.dato@gmail.com> | 2024-02-27 15:10:37 -0300 |
---|---|---|
committer | Nicolas Dato <nicolas.dato@gmail.com> | 2024-02-27 15:10:37 -0300 |
commit | 4b1b7cd304e4ec33eabe1690d32ddc9d2f384836 (patch) | |
tree | 23bee682a356792d37ee3464ccbdadd668a4f0ef | |
parent | 3c3935dc6d5ba6e4ed33bad1e969aa9888bd3a8a (diff) | |
download | libtuberia-4b1b7cd304e4ec33eabe1690d32ddc9d2f384836.tar.gz |
Adding itc_flush
-rw-r--r-- | src/itc.c | 14 | ||||
-rw-r--r-- | src/itc.h | 1 |
2 files changed, 15 insertions, 0 deletions
@@ -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; @@ -9,6 +9,7 @@ void itc_free(itc **ctx, itc_free_element free_element); void *itc_retrive(itc *ctx, int timeout_ms); int itc_inject(itc *ctx, int timeout_ms, void *element); +void itc_flush(itc *ctx); void itc_drop(itc *ctx, itc_free_element free_element); #endif //__LIBTUBERIA_ITC_H__ |