diff --git a/ChangeLog b/ChangeLog index b5c04f7c..3be50ed7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ xx/1/23 8.14.1 - add vips_thread_isworker() compatibility function [remicollet] +- add vips_semaphore_down_timeout() [kleisauke] +- idle threads are removed after 15s [kleisauke] +- fix version number in gtk-doc index [kleisauke] 22/12/22 8.14.0 diff --git a/libvips/deprecated/rename.c b/libvips/deprecated/rename.c index e3bc987e..476fa548 100644 --- a/libvips/deprecated/rename.c +++ b/libvips/deprecated/rename.c @@ -829,3 +829,11 @@ vips_free( void *buf ) return( 0 ); } +/* Use vips_thread_isvips() instead. + */ +gboolean +vips_thread_isworker( void ) +{ + return( vips_thread_isvips() ); +} + diff --git a/libvips/include/vips/semaphore.h b/libvips/include/vips/semaphore.h index 8c9ef0fa..75a05f81 100644 --- a/libvips/include/vips/semaphore.h +++ b/libvips/include/vips/semaphore.h @@ -58,14 +58,14 @@ typedef struct { VIPS_API int vips_semaphore_up( VipsSemaphore *s ); VIPS_API -int vips_semaphore_down( VipsSemaphore *s ); -VIPS_API -int vips_semaphore_down_timeout( VipsSemaphore *s, gint64 timeout ); -VIPS_API int vips_semaphore_upn( VipsSemaphore *s, int n ); VIPS_API +int vips_semaphore_down( VipsSemaphore *s ); +VIPS_API int vips_semaphore_downn( VipsSemaphore *s, int n ); VIPS_API +int vips_semaphore_down_timeout( VipsSemaphore *s, gint64 timeout ); +VIPS_API void vips_semaphore_destroy( VipsSemaphore *s ); VIPS_API void vips_semaphore_init( VipsSemaphore *s, int v, char *name ); diff --git a/libvips/iofuncs/semaphore.c b/libvips/iofuncs/semaphore.c index 96a67be2..606217e9 100644 --- a/libvips/iofuncs/semaphore.c +++ b/libvips/iofuncs/semaphore.c @@ -149,15 +149,18 @@ vips__semaphore_downn_until( VipsSemaphore *s, int n, gint64 end_time ) return( value_after_op ); } -/* Wait for sem>n, then subtract n. +/* Wait for sem>n, then subtract n. n must be >= 0. Returns the new semaphore + * value. */ int vips_semaphore_downn( VipsSemaphore *s, int n ) { + g_assert( n >= 0 ); + return( vips__semaphore_downn_until( s, n, -1 ) ); } -/* Wait for sem > 0, then decrement. +/* Wait for sem > 0, then decrement. Returns the new semaphore value. */ int vips_semaphore_down( VipsSemaphore *s ) @@ -166,8 +169,8 @@ vips_semaphore_down( VipsSemaphore *s ) } /* Wait for sem > 0, then decrement. - * Returns -1 when the relative time in @timeout (in microseconds) - * was passed. + * Returns -1 when @timeout (in microseconds) has passed, or the new + * semaphore value. */ int vips_semaphore_down_timeout( VipsSemaphore *s, gint64 timeout ) diff --git a/libvips/iofuncs/thread.c b/libvips/iofuncs/thread.c index 479e6142..4859538c 100644 --- a/libvips/iofuncs/thread.c +++ b/libvips/iofuncs/thread.c @@ -87,14 +87,6 @@ vips_thread_isvips( void ) return( g_private_get( is_vips_thread_key ) != NULL ); } -/* Deprecated compatibility function. - */ -gboolean -vips_thread_isworker( void ) -{ - return( vips_thread_isvips() ); -} - /* Glib 2.32 revised the thread API. We need some compat functions. */