libvips/libvips/include/vips/thread.h

73 lines
1.8 KiB
C
Raw Permalink Normal View History

2009-08-16 17:00:08 +02:00
/* Private include file ... if we've been configured without gthread, we need
* to point the g_thread_*() and g_mutex_*() functions at our own stubs.
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
2009-08-16 17:00:08 +02:00
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifndef VIPS_THREAD_H
#define VIPS_THREAD_H
2009-08-16 17:00:08 +02:00
#ifdef __cplusplus
extern "C" {
#endif /*__cplusplus*/
/* We need wrappers over g_mutex_new(), it was replaced by g_mutex_init() in
* glib 2.32+
2009-08-16 17:00:08 +02:00
*/
VIPS_API
2012-10-23 14:36:39 +02:00
GMutex *vips_g_mutex_new( void );
VIPS_API
2012-10-23 14:36:39 +02:00
void vips_g_mutex_free( GMutex * );
2009-08-16 17:00:08 +02:00
/* Same for GCond.
2012-10-23 13:55:38 +02:00
*/
VIPS_API
2012-10-23 14:36:39 +02:00
GCond *vips_g_cond_new( void );
VIPS_API
2012-10-23 14:36:39 +02:00
void vips_g_cond_free( GCond * );
/* ... and for GThread.
*/
VIPS_API
GThread *vips_g_thread_new( const char *, GThreadFunc, gpointer );
VIPS_API
Revised threading system (#3105) * reimplement threadpool just a set of threads that get recycled "ninja test" passes and dzsave seems to work, though pytest fails for some reason * clean up threading code a bit move base stuff into thread.c, so we have a simple thread -> threadset -> threadpool layering * start trying to revert g_threadpool based on the original commit * working! nice low systime again still need to repply cnages to threadpool.c since 80e0cc3d1 * reapply fixes from master so threadpool.c is now up to date * rename VipsThread as VipsWorker a bit less confusing * use a semaphore to count workers in a pool * tidy up * formatting * dynamic threadpool sizing based on counting the number of blocked threads in each pool it works, but the improvement is not great :( * add "concurrency" metadata item so operators can hint threadpool size (dzsave especially) * don't use thinstrip for small images * add RGB mode to openslide since flatten was taking 20% of CPU time for dzsave * fix up rgb mode now actually works * make the tile buffer per thread in the new openslideload rgb mode * fix dynamic pool downsize * mild refactoring * fix the buffer system oops, turned it off by mistake * all done! * revise changelog * Update libvips/iofuncs/threadset.c Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl> * Update libvips/iofuncs/threadset.c Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl> * LSan: add libMagickCore to suppression file * Revert "Remove mutex lock for VipsThreadStartFn" This reverts commit 41440491. * add VIPS_MAX_THREADS to set a hard limit on the threadset size * Revert "Revert "Remove mutex lock for VipsThreadStartFn"" This reverts commit 77e8520966ba79194fff3b4e648bbd295cd5c260. * remove sslock from sink.c * move fixed threadpool build to init not first use * add some doc comments * revert test suite threshold change * add a test for MAX_THREADS and move the test tmp/ area into the builddir * limit VIPS_MAX_THREADS to sane values * use tabs rather than spaces Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
2022-10-26 16:25:19 +02:00
gboolean vips_thread_isvips( void );
typedef struct _VipsThreadset VipsThreadset;
VipsThreadset *vips_threadset_new( int max_threads );
int vips_threadset_run( VipsThreadset *set,
const char *domain, GFunc func, gpointer data );
void vips_threadset_free( VipsThreadset *set );
2009-08-16 17:00:08 +02:00
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /*VIPS_THREAD_H*/