Skip to content

Commit

Permalink
iiod: thread_pool: Add function thread_pool_restart()
Browse files Browse the repository at this point in the history
This function can be used to re-activate a thread pool that has been
previously stopped with thread_pool_stop().

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Jun 5, 2023
1 parent e26bff1 commit f5f8422
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions iiod/thread-pool.c
Expand Up @@ -185,6 +185,14 @@ bool thread_pool_is_stopped(const struct thread_pool *pool)
return pool->stop;
}

void thread_pool_restart(struct thread_pool *pool)
{
if (pool->stop) {
thread_pool_purge_events(pool);
pool->stop = false;
}
}

void thread_pool_destroy(struct thread_pool *pool)
{
pthread_mutex_destroy(&pool->thread_count_lock);
Expand Down
1 change: 1 addition & 0 deletions iiod/thread-pool.h
Expand Up @@ -19,6 +19,7 @@ int thread_pool_get_poll_fd(const struct thread_pool *pool);
void thread_pool_stop(struct thread_pool *pool);
void thread_pool_stop_and_wait(struct thread_pool *pool);
bool thread_pool_is_stopped(const struct thread_pool *pool);
void thread_pool_restart(struct thread_pool *pool);

void thread_pool_destroy(struct thread_pool *pool);

Expand Down

0 comments on commit f5f8422

Please sign in to comment.