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
|
- tilecache speedups
|
||||||
- add vips_heifload(), vips_heifsave()
|
- add vips_heifload(), vips_heifsave()
|
||||||
- add heif thumbnail support to vips_thumbnail()
|
- 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
|
4/1/19 started 8.7.4
|
||||||
- magickload with magick6 API did not chain exceptions correctly causing a
|
- magickload with magick6 API did not chain exceptions correctly causing a
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
* 23/4/17
|
* 23/4/17
|
||||||
* - add ->stall
|
* - add ->stall
|
||||||
* - don't depend on image width when setting n_lines
|
* - 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 );
|
VIPS_FREEF( g_object_unref, thr->state );
|
||||||
thr->pool = NULL;
|
thr->pool = NULL;
|
||||||
/* Free the thread memory
|
|
||||||
*/
|
VIPS_FREE( thr );
|
||||||
g_free(thr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -591,10 +592,9 @@ vips_thread_allocate( VipsThread *thr )
|
|||||||
|
|
||||||
g_assert( !pool->stop );
|
g_assert( !pool->stop );
|
||||||
|
|
||||||
if( !thr->state ) {
|
if( !thr->state &&
|
||||||
if( !(thr->state = pool->start( pool->im, pool->a )) )
|
!(thr->state = pool->start( pool->im, pool->a )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
|
||||||
|
|
||||||
if( pool->allocate( thr->state, pool->a, &pool->stop ) )
|
if( pool->allocate( thr->state, pool->a, &pool->stop ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -728,7 +728,8 @@ vips_thread_new( VipsThreadpool *pool )
|
|||||||
return( thr );
|
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
|
static void
|
||||||
vips_threadpool_kill_threads( VipsThreadpool *pool )
|
vips_threadpool_kill_threads( VipsThreadpool *pool )
|
||||||
@ -737,23 +738,14 @@ vips_threadpool_kill_threads( VipsThreadpool *pool )
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < pool->nthr; i++ )
|
for( i = 0; i < pool->nthr; i++ )
|
||||||
if( pool->thr[i] ) {
|
VIPS_FREEF( vips_thread_free, 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_DEBUG_MSG( "vips_threadpool_kill_threads: "
|
VIPS_DEBUG_MSG( "vips_threadpool_kill_threads: "
|
||||||
"killed %d threads\n", pool->nthr );
|
"killed %d threads\n", pool->nthr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This can be called multiple times, careful.
|
static void
|
||||||
*/
|
|
||||||
static int
|
|
||||||
vips_threadpool_free( VipsThreadpool *pool )
|
vips_threadpool_free( VipsThreadpool *pool )
|
||||||
{
|
{
|
||||||
VIPS_DEBUG_MSG( "vips_threadpool_free: \"%s\" (%p)\n",
|
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_FREEF( vips_g_mutex_free, pool->allocate_lock );
|
||||||
vips_semaphore_destroy( &pool->finish );
|
vips_semaphore_destroy( &pool->finish );
|
||||||
vips_semaphore_destroy( &pool->tick );
|
vips_semaphore_destroy( &pool->tick );
|
||||||
/* Free pool memory
|
VIPS_FREE( pool->thr );
|
||||||
*/
|
VIPS_FREE( pool );
|
||||||
g_free(pool);
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
vips_threadpool_new_cb( VipsImage *im, VipsThreadpool *pool )
|
|
||||||
{
|
|
||||||
vips_threadpool_free( pool );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VipsThreadpool *
|
static VipsThreadpool *
|
||||||
|
Loading…
Reference in New Issue
Block a user