Skip to content

Commit

Permalink
Cleanup a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Sep 8, 2024
1 parent ab57497 commit f91679a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion libvips/include/vips/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ extern gboolean vips__cache_trace;
void vips__thread_init(void);
void vips__threadpool_init(void);
void vips__threadpool_shutdown(void);
int vips__thread_execute(const char *name, GFunc func, gpointer data);
VIPS_API void vips__worker_lock(GMutex *mutex);

void vips__cache_init(void);
Expand Down
11 changes: 8 additions & 3 deletions libvips/iofuncs/threadset.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ vips_threadset_work(void *pointer)

/* Timed-out or exit has been requested, decrement number of threads.
*/
set->n_threads -= 1;
set->n_threads--;
gboolean signal_last = set->exit && set->n_threads == 0;
VIPS_DEBUG_MSG("vips_threadset_work: stopping %p (%d remaining)\n",
g_thread_self(), set->n_threads);
Expand Down Expand Up @@ -174,7 +174,7 @@ vips_threadset_add_thread(VipsThreadset *set)
*/
g_thread_unref(thread);

set->n_threads += 1;
set->n_threads++;
set->n_threads_highwater =
VIPS_MAX(set->n_threads_highwater, set->n_threads);

Expand Down Expand Up @@ -247,9 +247,14 @@ vips_threadset_run(VipsThreadset *set,

g_async_queue_lock(set->queue);

/* The queue length is calculated as the number of tasks in the queue
* minus the number of waiting threads.
*/
const int queue_length = g_async_queue_length_unlocked(set->queue);

/* Create a new thread if there are no waiting threads in the queue.
*/
if (g_async_queue_length_unlocked(set->queue) >= 0)
if (queue_length >= 0)
if (vips_threadset_add_thread(set)) {
g_async_queue_unlock(set->queue);

Expand Down

0 comments on commit f91679a

Please sign in to comment.