better render init stops a race

when running inside some versions of gdb
This commit is contained in:
John Cupitt 2020-04-02 14:23:06 +01:00
parent 78f927e606
commit 8840bc8a14
3 changed files with 4 additions and 9 deletions

View File

@ -114,6 +114,7 @@ void vips__threadpool_init( void );
void vips__cache_init( void ); void vips__cache_init( void );
void vips__sink_screen_init( void );
void vips__print_renders( void ); void vips__print_renders( void );
void vips__type_leak( void ); void vips__type_leak( void );

View File

@ -384,6 +384,7 @@ vips_init( const char *argv0 )
#endif /*HAVE_THREAD_NEW*/ #endif /*HAVE_THREAD_NEW*/
vips__threadpool_init(); vips__threadpool_init();
vips__sink_screen_init();
vips__buffer_init(); vips__buffer_init();
vips__meta_init(); vips__meta_init();

View File

@ -1029,8 +1029,8 @@ render_thread_main( void *client )
return( NULL ); return( NULL );
} }
static void void
vips_sink_screen_init( void ) vips__sink_screen_init( void )
{ {
g_assert( !render_thread ); g_assert( !render_thread );
g_assert( !render_dirty_lock ); g_assert( !render_dirty_lock );
@ -1039,9 +1039,6 @@ vips_sink_screen_init( void )
render_thread = vips_g_thread_new( "sink_screen", render_thread = vips_g_thread_new( "sink_screen",
render_thread_main, NULL ); render_thread_main, NULL );
vips_semaphore_init( &n_render_dirty_sem, 0, "n_render_dirty" ); vips_semaphore_init( &n_render_dirty_sem, 0, "n_render_dirty" );
g_assert( render_thread );
g_assert( render_dirty_lock );
} }
/** /**
@ -1101,12 +1098,8 @@ vips_sink_screen( VipsImage *in, VipsImage *out, VipsImage *mask,
int priority, int priority,
VipsSinkNotify notify_fn, void *a ) VipsSinkNotify notify_fn, void *a )
{ {
static GOnce once = G_ONCE_INIT;
Render *render; Render *render;
VIPS_ONCE( &once, (GThreadFunc) vips_sink_screen_init, NULL );
if( tile_width <= 0 || tile_height <= 0 || if( tile_width <= 0 || tile_height <= 0 ||
max_tiles < -1 ) { max_tiles < -1 ) {
vips_error( "vips_sink_screen", "%s", _( "bad parameters" ) ); vips_error( "vips_sink_screen", "%s", _( "bad parameters" ) );