Skip to content

Commit f5f8422

Browse files
committed
iiod: thread_pool: Add function thread_pool_restart()
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 <[email protected]>
1 parent e26bff1 commit f5f8422

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

iiod/thread-pool.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ bool thread_pool_is_stopped(const struct thread_pool *pool)
185185
return pool->stop;
186186
}
187187

188+
void thread_pool_restart(struct thread_pool *pool)
189+
{
190+
if (pool->stop) {
191+
thread_pool_purge_events(pool);
192+
pool->stop = false;
193+
}
194+
}
195+
188196
void thread_pool_destroy(struct thread_pool *pool)
189197
{
190198
pthread_mutex_destroy(&pool->thread_count_lock);

iiod/thread-pool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ int thread_pool_get_poll_fd(const struct thread_pool *pool);
1919
void thread_pool_stop(struct thread_pool *pool);
2020
void thread_pool_stop_and_wait(struct thread_pool *pool);
2121
bool thread_pool_is_stopped(const struct thread_pool *pool);
22+
void thread_pool_restart(struct thread_pool *pool);
2223

2324
void thread_pool_destroy(struct thread_pool *pool);
2425

0 commit comments

Comments
 (0)