start up threadpool later

might help php and ruby web frameworks

see eg. https://github.com/libvips/php-vips-ext/issues/42
This commit is contained in:
John Cupitt 2021-07-14 20:21:38 +01:00
parent ee865253a6
commit 6946c3b9d9
3 changed files with 30 additions and 10 deletions

View File

@ -1,9 +1,12 @@
14/8/20 started 8.11.2 14/7/21 started 8.11.3
- build threadpool later [kleisauke]
15/6/20 started 8.11.2
- better libdir guessing [remi] - better libdir guessing [remi]
- fix tiff pyramid creation with jp2k compression (was broken by 8.11.1) - fix tiff pyramid creation with jp2k compression (was broken by 8.11.1)
- don't load modules if we're built without modules - don't load modules if we're built without modules
14/8/20 started 8.11.1 18/6/21 started 8.11.1
- add more example code to C docs - add more example code to C docs
- update libtool support in configure.ac - update libtool support in configure.ac
- more startup info if VIPS_INFO is set - more startup info if VIPS_INFO is set

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below # also update the version number in the m4 macros below
AC_INIT([vips],[8.11.2],[vipsip@jiscmail.ac.uk]) AC_INIT([vips],[8.11.3],[vipsip@jiscmail.ac.uk])
# required for gobject-introspection # required for gobject-introspection
AC_PREREQ([2.69]) AC_PREREQ([2.69])
@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning # user-visible library versioning
m4_define([vips_major_version], [8]) m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [11]) m4_define([vips_minor_version], [11])
m4_define([vips_micro_version], [2]) m4_define([vips_micro_version], [3])
m4_define([vips_version], m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version]) [vips_major_version.vips_minor_version.vips_micro_version])
@ -43,7 +43,7 @@ VIPS_LIBS=""
# binary interface changes not backwards compatible?: reset age to 0 # binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=55 LIBRARY_CURRENT=55
LIBRARY_REVISION=1 LIBRARY_REVISION=2
LIBRARY_AGE=13 LIBRARY_AGE=13
# patched into include/vips/version.h # patched into include/vips/version.h

View File

@ -731,6 +731,19 @@ vips_task_free( VipsTask *task )
VIPS_FREE( task ); VIPS_FREE( task );
} }
static void *
vips__thread_once_init( void *data )
{
/* We can have many more than vips__concurrency threads -- each active
* pipeline will make vips__concurrency more, see
* vips_threadpool_run().
*/
vips__pool = g_thread_pool_new( vips_thread_main_loop, NULL,
-1, FALSE, NULL );
return( NULL );
}
/** /**
* vips__thread_execute: * vips__thread_execute:
* @name: a name for the thread * @name: a name for the thread
@ -747,10 +760,14 @@ vips_task_free( VipsTask *task )
int int
vips__thread_execute( const char *name, GFunc func, gpointer data ) vips__thread_execute( const char *name, GFunc func, gpointer data )
{ {
static GOnce once = G_ONCE_INIT;
VipsThreadExec *exec; VipsThreadExec *exec;
GError *error = NULL; GError *error = NULL;
gboolean result; gboolean result;
VIPS_ONCE( &once, vips__thread_once_init, NULL );
exec = g_new( VipsThreadExec, 1 ); exec = g_new( VipsThreadExec, 1 );
exec->name = name; exec->name = name;
exec->func = func; exec->func = func;
@ -948,12 +965,12 @@ vips__threadpool_init( void )
if( vips__concurrency == 0 ) if( vips__concurrency == 0 )
vips__concurrency = vips__concurrency_get_default(); vips__concurrency = vips__concurrency_get_default();
/* We can have many more than vips__concurrency threads -- each active /* The threadpool is built in the first vips__thread_execute()
* pipeline will make vips__concurrency more, see * call, since we want thread creation to happen as late as possible.
* vips_threadpool_run(). *
* Many web platforms start up in a base environment, then fork() for
* each request. We must not make the threadpool before the fork.
*/ */
vips__pool = g_thread_pool_new( vips_thread_main_loop, NULL,
-1, FALSE, NULL );
VIPS_DEBUG_MSG( "vips__threadpool_init: (%p)\n", vips__pool ); VIPS_DEBUG_MSG( "vips__threadpool_init: (%p)\n", vips__pool );
} }