mild refactoring of threadpool
clean up and simplify after https://github.com/libvips/libvips/pull/1240
This commit is contained in:
parent
3324ed8a2f
commit
a05a2cb52d
@ -25,6 +25,8 @@
|
||||
- tilecache speedups
|
||||
- add vips_heifload(), vips_heifsave()
|
||||
- add heif thumbnail support to vips_thumbnail()
|
||||
- free threadpool earlier, reducing mem growth for some long-running
|
||||
processes [jtorresfabra]
|
||||
|
||||
4/1/19 started 8.7.4
|
||||
- magickload with magick6 API did not chain exceptions correctly causing a
|
||||
|
@ -21,6 +21,8 @@
|
||||
* 23/4/17
|
||||
* - add ->stall
|
||||
* - don't depend on image width when setting n_lines
|
||||
* 27/2/19 jtorresfabra
|
||||
* - free threadpool earlier
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -579,9 +581,8 @@ vips_thread_free( VipsThread *thr )
|
||||
|
||||
VIPS_FREEF( g_object_unref, thr->state );
|
||||
thr->pool = NULL;
|
||||
/* Free the thread memory
|
||||
*/
|
||||
g_free(thr);
|
||||
|
||||
VIPS_FREE( thr );
|
||||
}
|
||||
|
||||
static int
|
||||
@ -591,10 +592,9 @@ vips_thread_allocate( VipsThread *thr )
|
||||
|
||||
g_assert( !pool->stop );
|
||||
|
||||
if( !thr->state ) {
|
||||
if( !(thr->state = pool->start( pool->im, pool->a )) )
|
||||
return( -1 );
|
||||
}
|
||||
if( !thr->state &&
|
||||
!(thr->state = pool->start( pool->im, pool->a )) )
|
||||
return( -1 );
|
||||
|
||||
if( pool->allocate( thr->state, pool->a, &pool->stop ) )
|
||||
return( -1 );
|
||||
@ -728,7 +728,8 @@ vips_thread_new( VipsThreadpool *pool )
|
||||
return( thr );
|
||||
}
|
||||
|
||||
/* Kill all threads in a threadpool, if there are any.
|
||||
/* Kill all threads in a threadpool, if there are any. Can be called multiple
|
||||
* times.
|
||||
*/
|
||||
static void
|
||||
vips_threadpool_kill_threads( VipsThreadpool *pool )
|
||||
@ -737,23 +738,14 @@ vips_threadpool_kill_threads( VipsThreadpool *pool )
|
||||
int i;
|
||||
|
||||
for( i = 0; i < pool->nthr; i++ )
|
||||
if( pool->thr[i] ) {
|
||||
vips_thread_free( pool->thr[i] );
|
||||
pool->thr[i] = NULL;
|
||||
}
|
||||
/* Free the thread array
|
||||
*/
|
||||
g_free(pool->thr);
|
||||
pool->thr = NULL;
|
||||
VIPS_FREEF( vips_thread_free, pool->thr[i] );
|
||||
|
||||
VIPS_DEBUG_MSG( "vips_threadpool_kill_threads: "
|
||||
"killed %d threads\n", pool->nthr );
|
||||
}
|
||||
}
|
||||
|
||||
/* This can be called multiple times, careful.
|
||||
*/
|
||||
static int
|
||||
static void
|
||||
vips_threadpool_free( VipsThreadpool *pool )
|
||||
{
|
||||
VIPS_DEBUG_MSG( "vips_threadpool_free: \"%s\" (%p)\n",
|
||||
@ -763,16 +755,8 @@ vips_threadpool_free( VipsThreadpool *pool )
|
||||
VIPS_FREEF( vips_g_mutex_free, pool->allocate_lock );
|
||||
vips_semaphore_destroy( &pool->finish );
|
||||
vips_semaphore_destroy( &pool->tick );
|
||||
/* Free pool memory
|
||||
*/
|
||||
g_free(pool);
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_threadpool_new_cb( VipsImage *im, VipsThreadpool *pool )
|
||||
{
|
||||
vips_threadpool_free( pool );
|
||||
VIPS_FREE( pool->thr );
|
||||
VIPS_FREE( pool );
|
||||
}
|
||||
|
||||
static VipsThreadpool *
|
||||
|
Loading…
Reference in New Issue
Block a user