threadgroup

threadgroup — groups of worker threads

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

                    im_thread_t;
int                 (*im__work_fn)                      (im_thread_t *thr,
                                                         REGION *,
                                                         void *,
                                                         void *,
                                                         void *);
                    im_threadgroup_t;
void                im_concurrency_set                  (int concurrency);
int                 im_concurrency_get                  (void);
im_threadgroup_t *  im_threadgroup_create               (IMAGE *im);
int                 im_threadgroup_free                 (im_threadgroup_t *tg);
im_thread_t *       im_threadgroup_get                  (im_threadgroup_t *tg);
void                im_threadgroup_trigger              (im_thread_t *thr);
void                im_threadgroup_wait                 (im_threadgroup_t *tg);
int                 im_threadgroup_iserror              (im_threadgroup_t *tg);
int                 im_prepare_thread                   (im_threadgroup_t *tg,
                                                         REGION *oreg,
                                                         Rect *r);
int                 (*im_wbuffer_fn)                    (REGION *region,
                                                         Rect *area,
                                                         void *a,
                                                         void *b);
int                 im_wbuffer                          (im_threadgroup_t *tg,
                                                         im_wbuffer_fn write_fn,
                                                         void *a,
                                                         void *b);

Description

VIPS has its own threadpool system, used by (for example) im_prepare_thread().

Most of this is internal to VIPS and does not need to be documented. You should only need im_threadgroup_create() and im_threadgroup_free().

Details

im_thread_t

typedef struct {
	/* All private.
	 */
} im_thread_t;

im__work_fn ()

int                 (*im__work_fn)                      (im_thread_t *thr,
                                                         REGION *,
                                                         void *,
                                                         void *,
                                                         void *);

im_threadgroup_t

typedef struct {
	/* All private.
	 */
} im_threadgroup_t;

im_concurrency_set ()

void                im_concurrency_set                  (int concurrency);

im_concurrency_get ()

int                 im_concurrency_get                  (void);

im_threadgroup_create ()

im_threadgroup_t *  im_threadgroup_create               (IMAGE *im);

Makes a threadgroup attached to the image. The threadgroup will be freed for you if the image is closed, but you can free it yourself with im_threadgroup_free() if you wish.

See also: im_threadgroup_free(), im_prepare_thread().

im :

image to create the threadgroup on

Returns :

an im_threadgroup_t on success, NULL on error.

im_threadgroup_free ()

int                 im_threadgroup_free                 (im_threadgroup_t *tg);

Frees a threadgroup. This function can be called multiple times, though only the first time will have any effect.

All worker threads are terminated and all resources freed.

See also: im_threadgroup_create().

tg :

threadgroup to free

Returns :

0.

im_threadgroup_get ()

im_thread_t *       im_threadgroup_get                  (im_threadgroup_t *tg);

im_threadgroup_trigger ()

void                im_threadgroup_trigger              (im_thread_t *thr);

im_threadgroup_wait ()

void                im_threadgroup_wait                 (im_threadgroup_t *tg);

im_threadgroup_iserror ()

int                 im_threadgroup_iserror              (im_threadgroup_t *tg);

im_prepare_thread ()

int                 im_prepare_thread                   (im_threadgroup_t *tg,
                                                         REGION *oreg,
                                                         Rect *r);

im_prepare_thread() fills reg with pixels. After calling, you can address at least the area r with IM_REGION_ADDR() and get valid pixels.

im_prepare_thread() uses tg, a group of threads, to calculate pixels. Computation blocks until the pixels are ready.

Use im_prepare() to calculate an area of pixels in-line. Use im_render_priority() to calculate an area of pixels in the background.

See also: im_prepare(), im_render_priority(), im_prepare_to().

tg :

group of threads to evaluate with

reg :

region to prepare

r :

Rect of pixels you need to be able to address

Returns :

0 on success, or -1 on error

im_wbuffer_fn ()

int                 (*im_wbuffer_fn)                    (REGION *region,
                                                         Rect *area,
                                                         void *a,
                                                         void *b);

im_wbuffer ()

int                 im_wbuffer                          (im_threadgroup_t *tg,
                                                         im_wbuffer_fn write_fn,
                                                         void *a,
                                                         void *b);

See Also

generate