Skip to content

Commit 80e0cc3

Browse files
committed
Reuse threads by using GLib's threadpool
1 parent 1423c55 commit 80e0cc3

File tree

4 files changed

+270
-277
lines changed

4 files changed

+270
-277
lines changed

libvips/include/vips/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ extern gboolean vips__cache_trace;
111111
extern int vips__n_active_threads;
112112

113113
void vips__threadpool_init( void );
114+
void vips__threadpool_shutdown( void );
114115

115116
void vips__cache_init( void );
116117

libvips/include/vips/threadpool.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* 17/3/10
66
* - from threadgroup
77
* - rework with a simpler distributed work allocation model
8+
* 02/02/20 kleisauke
9+
* - reuse threads by using GLib's threadpool
810
*/
911

1012
/*
@@ -130,6 +132,7 @@ typedef int (*VipsThreadpoolWorkFn)( VipsThreadState *state, void *a );
130132
*/
131133
typedef int (*VipsThreadpoolProgressFn)( void *a );
132134

135+
int vips_threadpool_push( const char *name, GFunc func, gpointer data );
133136
int vips_threadpool_run( VipsImage *im,
134137
VipsThreadStartFn start,
135138
VipsThreadpoolAllocateFn allocate,

libvips/iofuncs/init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ vips_leak( void )
665665
*
666666
* This function needs to be called when a thread that has been using vips
667667
* exits. It is called for you by vips_shutdown() and for any threads created
668-
* by vips_g_thread_new().
668+
* within the #VipsThreadPool.
669669
*
670670
* You will need to call it from threads created in
671671
* other ways or there will be memory leaks. If you do not call it, vips
@@ -719,6 +719,8 @@ vips_shutdown( void )
719719

720720
vips__thread_profile_stop();
721721

722+
vips__threadpool_shutdown();
723+
722724
#ifdef HAVE_GSF
723725
gsf_shutdown();
724726
#endif /*HAVE_GSF*/

0 commit comments

Comments
 (0)