Function

Vipsthreadpool_run

Declaration [src]

int
vips_threadpool_run (
  VipsImage* im,
  VipsThreadStartFn start,
  VipsThreadpoolAllocateFn allocate,
  VipsThreadpoolWorkFn work,
  VipsThreadpoolProgressFn progress,
  void* a
)

Description [src]

This function runs a set of threads over an image. Each thread first calls start to create new per-thread state, then runs allocate to set up a new work unit (perhaps the next tile in an image, for example), then work to process that work unit. After each unit is processed, progress is called, so that the operation can give progress feedback. progress may be NULL.

The object returned by start must be an instance of a subclass of VipsThreadState. Use this to communicate between allocate and work.

allocate and start are always single-threaded (so they can write to the per-pool state), whereas work can be executed concurrently. progress is always called by the main thread (ie. the thread which called vips_threadpool_run()).

::: seealso vips_concurrency_set().

Parameters

im VipsImage
 

Image to loop over.

 The data is owned by the caller of the function.
start VipsThreadStartFn
 

Allocate per-thread state.

allocate VipsThreadpoolAllocateFn
 

Allocate a work unit.

work VipsThreadpoolWorkFn
 

Process a work unit.

progress VipsThreadpoolProgressFn
 

Give progress feedback about a work unit, or NULL

a void*
 

Client data.

 The argument can be NULL.
 The data is owned by the caller of the function.

Return value

Returns: int
 

0 on success, or -1 on error.