move vips_threadpool_push to internal API

and rename as vips__thread_execute()
This commit is contained in:
John Cupitt 2021-05-17 08:42:39 +01:00
parent 77ab3d2562
commit f637206e8d
5 changed files with 15 additions and 15 deletions

View File

@ -110,6 +110,7 @@ extern gboolean vips__cache_trace;
void vips__threadpool_init( void );
void vips__threadpool_shutdown( void );
int vips__thread_execute( const char *name, GFunc func, gpointer data );
void vips__cache_init( void );

View File

@ -132,7 +132,6 @@ typedef int (*VipsThreadpoolWorkFn)( VipsThreadState *state, void *a );
*/
typedef int (*VipsThreadpoolProgressFn)( void *a );
int vips_threadpool_push( const char *name, GFunc func, gpointer data );
int vips_threadpool_run( VipsImage *im,
VipsThreadStartFn start,
VipsThreadpoolAllocateFn allocate,

View File

@ -236,7 +236,7 @@ wbuffer_new( Write *write )
/* Make this last (picks up parts of wbuffer on startup).
*/
if( vips_threadpool_push( "wbuffer", wbuffer_write_thread,
if( vips__thread_execute( "wbuffer", wbuffer_write_thread,
wbuffer ) ) {
wbuffer_free( wbuffer );
return( NULL );

View File

@ -70,6 +70,7 @@
#include <vips/vips.h>
#include <vips/thread.h>
#include <vips/internal.h>
#include <vips/debug.h>
#ifdef VIPS_DEBUG_AMBER
@ -1069,10 +1070,10 @@ vips__sink_screen_init( void *data )
vips_semaphore_init( &n_render_dirty_sem, 0, "n_render_dirty" );
vips_semaphore_init( &render_finish, 0, "render_finish" );
if ( vips_threadpool_push( "sink_screen", render_thread_main,
if( vips__thread_execute( "sink_screen", render_thread_main,
NULL ) ) {
vips_error("vips_sink_screen_init", "%s",
_("unable to init render thread"));
vips_error( "vips_sink_screen_init",
"%s", _( "unable to init render thread" ) );
return( NULL );
}

View File

@ -661,21 +661,20 @@ vips_task_free( VipsTask *task )
}
/**
* vips_threadpool_push:
* @name an name for the thread
* @func a function to execute in the thread pool
* @data an argument to supply to @func
* vips__thread_execute:
* @name: a name for the thread
* @func: a function to execute in the thread pool
* @data: an argument to supply to @func
*
* Add a new function to the list of tasks to be executed by the
* #VipsThreadPool. A newly created or reused thread will execute
* @func with with the argument data.
* A newly created or reused thread will execute @func with with the
* argument data.
*
* See also: vips_concurrency_set().
*
* Returns: 0 on success, -1 on error.
*/
int
vips_threadpool_push( const char *name, GFunc func, gpointer data )
vips__thread_execute( const char *name, GFunc func, gpointer data )
{
VipsThreadExec *exec;
GError *error = NULL;
@ -692,7 +691,7 @@ vips_threadpool_push( const char *name, GFunc func, gpointer data )
return( -1 );
}
VIPS_DEBUG_MSG( "vips_threadpool_push: %u threads in pool\n",
VIPS_DEBUG_MSG( "vips__thread_execute: %u threads in pool\n",
g_thread_pool_get_num_threads( vips__pool ) );
return( result ? 0 : -1 );
@ -825,7 +824,7 @@ vips_threadpool_run( VipsImage *im,
/* Create a set of workers for this pipeline.
*/
for( i = 0; i < n_tasks; i++ )
if( vips_threadpool_push( "worker", vips_task_run, task ) )
if( vips__thread_execute( "worker", vips_task_run, task ) )
return( -1 );
for(;;) {