From 1a915db678762bee2046a63a30aac0d2213f2db0 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 19 Oct 2016 09:58:13 +0100 Subject: [PATCH] no longer need to clean up main buffers thread-private buffers are now only on workers, no need to to start them up or free them on the main thread --- libvips/include/vips/internal.h | 1 - libvips/iofuncs/buffer.c | 15 ++++----------- libvips/iofuncs/init.c | 5 ----- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index 6d32afa2..2866011c 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -133,7 +133,6 @@ int vips_mapfilerw( VipsImage * ); int vips_remapfilerw( VipsImage * ); void vips__buffer_init( void ); -void vips__buffer_shutdown( void ); void vips__copy_4byte( int swap, unsigned char *to, unsigned char *from ); void vips__copy_2byte( gboolean swap, unsigned char *to, unsigned char *from ); diff --git a/libvips/iofuncs/buffer.c b/libvips/iofuncs/buffer.c index 8f50cb86..e315b5ce 100644 --- a/libvips/iofuncs/buffer.c +++ b/libvips/iofuncs/buffer.c @@ -652,7 +652,7 @@ buffer_thread_destroy_notify( VipsBufferThread *buffer_thread ) buffer_thread_free( buffer_thread ); } -/* Init the buffer cache system. +/* Init the buffer cache system. This must only be called from worker threads. */ void vips__buffer_init( void ) @@ -671,6 +671,9 @@ vips__buffer_init( void ) if( buffer_cache_max_reserve < 1 ) printf( "vips__buffer_init: buffer reserve disabled\n" ); + if( !vips_thread_isworker() ) + printf( "vips__buffer_init: called for non-worker\n" ); + #ifdef DEBUG printf( "vips__buffer_init: DEBUG enabled\n" ); #endif /*DEBUG*/ @@ -680,13 +683,3 @@ vips__buffer_init( void ) #endif /*DEBUG_CREATE*/ } -void -vips__buffer_shutdown( void ) -{ - VipsBufferThread *buffer_thread; - - if( (buffer_thread = g_private_get( buffer_thread_key )) ) { - buffer_thread_free( buffer_thread ); - g_private_set( buffer_thread_key, NULL ); - } -} diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index fb492808..807903de 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -400,10 +400,6 @@ vips_init( const char *argv0 ) vips_error_clear(); } - /* Start up the buffer cache. - */ - vips__buffer_init(); - /* Get the run-time compiler going. */ vips_vector_init(); @@ -512,7 +508,6 @@ vips_leak( void ) void vips_thread_shutdown( void ) { - vips__buffer_shutdown(); vips__thread_profile_detach(); }