"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libvips/iofuncs/sinkdisc.c" between
vips-8.10.6.tar.gz and vips-8.11.0.tar.gz

About: VIPS is a free image processing system (see also the GUI nip2).

sinkdisc.c  (vips-8.10.6):sinkdisc.c  (vips-8.11.0)
skipping to change at line 78 skipping to change at line 78
/* A buffer we are going to write to disc in a background thread. /* A buffer we are going to write to disc in a background thread.
*/ */
typedef struct _WriteBuffer { typedef struct _WriteBuffer {
struct _Write *write; struct _Write *write;
VipsRegion *region; /* Pixels */ VipsRegion *region; /* Pixels */
VipsRect area; /* Part of image this region covers */ VipsRect area; /* Part of image this region covers */
VipsSemaphore go; /* Start bg thread loop */ VipsSemaphore go; /* Start bg thread loop */
VipsSemaphore nwrite; /* Number of threads writing to region */ VipsSemaphore nwrite; /* Number of threads writing to region */
VipsSemaphore done; /* Bg thread has done write */ VipsSemaphore done; /* Bg thread has done write */
VipsSemaphore finish; /* Bg thread has finished */
int write_errno; /* Save write errors here */ int write_errno; /* Save write errors here */
GThread *thread; /* BG writer thread */ gboolean running; /* Whether the bg writer thread is running */
gboolean kill; /* Set to ask thread to exit */ gboolean kill; /* Set to ask thread to exit */
} WriteBuffer; } WriteBuffer;
/* Per-call state. /* Per-call state.
*/ */
typedef struct _Write { typedef struct _Write {
SinkBase sink_base; SinkBase sink_base;
/* We are current writing tiles to buf, buf_back is in the hands of /* We are current writing tiles to buf, buf_back is in the hands of
* the bg write thread. * the bg write thread.
skipping to change at line 144 skipping to change at line 145
return( VIPS_THREAD_STATE( vips_object_new( return( VIPS_THREAD_STATE( vips_object_new(
write_thread_state_get_type(), write_thread_state_get_type(),
vips_thread_state_set, im, a ) ) ); vips_thread_state_set, im, a ) ) );
} }
static void static void
wbuffer_free( WriteBuffer *wbuffer ) wbuffer_free( WriteBuffer *wbuffer )
{ {
/* Is there a thread running this region? Kill it! /* Is there a thread running this region? Kill it!
*/ */
if( wbuffer->thread ) { if( wbuffer->running ) {
wbuffer->kill = TRUE; wbuffer->kill = TRUE;
vips_semaphore_up( &wbuffer->go ); vips_semaphore_up( &wbuffer->go );
/* Return value is always NULL (see wbuffer_write_thread). vips_semaphore_down( &wbuffer->finish );
*/
(void) vips_g_thread_join( wbuffer->thread ); VIPS_DEBUG_MSG( "wbuffer_free:\n" );
VIPS_DEBUG_MSG( "wbuffer_free: vips_g_thread_join()\n" );
wbuffer->thread = NULL; wbuffer->running = FALSE;
} }
VIPS_UNREF( wbuffer->region ); VIPS_UNREF( wbuffer->region );
vips_semaphore_destroy( &wbuffer->go ); vips_semaphore_destroy( &wbuffer->go );
vips_semaphore_destroy( &wbuffer->nwrite ); vips_semaphore_destroy( &wbuffer->nwrite );
vips_semaphore_destroy( &wbuffer->done ); vips_semaphore_destroy( &wbuffer->done );
vips_semaphore_destroy( &wbuffer->finish );
g_free( wbuffer ); g_free( wbuffer );
} }
static void static void
wbuffer_write( WriteBuffer *wbuffer ) wbuffer_write( WriteBuffer *wbuffer )
{ {
Write *write = wbuffer->write; Write *write = wbuffer->write;
VIPS_DEBUG_MSG( "wbuffer_write: %d bytes from wbuffer %p\n", VIPS_DEBUG_MSG( "wbuffer_write: %d bytes from wbuffer %p\n",
wbuffer->region->bpl * wbuffer->area.height, wbuffer ); wbuffer->region->bpl * wbuffer->area.height, wbuffer );
skipping to change at line 181 skipping to change at line 182
VIPS_GATE_START( "wbuffer_write: work" ); VIPS_GATE_START( "wbuffer_write: work" );
wbuffer->write_errno = write->write_fn( wbuffer->region, wbuffer->write_errno = write->write_fn( wbuffer->region,
&wbuffer->area, write->a ); &wbuffer->area, write->a );
VIPS_GATE_STOP( "wbuffer_write: work" ); VIPS_GATE_STOP( "wbuffer_write: work" );
} }
/* Run this as a thread to do a BG write. /* Run this as a thread to do a BG write.
*/ */
static void * static void
wbuffer_write_thread( void *data ) wbuffer_write_thread( void *data, void *user_data )
{ {
WriteBuffer *wbuffer = (WriteBuffer *) data; WriteBuffer *wbuffer = (WriteBuffer *) data;
for(;;) { for(;;) {
/* Wait to be told to write. /* Wait to be told to write.
*/ */
vips_semaphore_down( &wbuffer->go ); vips_semaphore_down( &wbuffer->go );
if( wbuffer->kill ) if( wbuffer->kill )
break; break;
skipping to change at line 205 skipping to change at line 206
*/ */
vips_semaphore_downn( &wbuffer->nwrite, 0 ); vips_semaphore_downn( &wbuffer->nwrite, 0 );
wbuffer_write( wbuffer ); wbuffer_write( wbuffer );
/* Signal write complete. /* Signal write complete.
*/ */
vips_semaphore_up( &wbuffer->done ); vips_semaphore_up( &wbuffer->done );
} }
return( NULL ); /* We are exiting: tell the main thread.
*/
vips_semaphore_up( &wbuffer->finish );
} }
static WriteBuffer * static WriteBuffer *
wbuffer_new( Write *write ) wbuffer_new( Write *write )
{ {
WriteBuffer *wbuffer; WriteBuffer *wbuffer;
if( !(wbuffer = VIPS_NEW( NULL, WriteBuffer )) ) if( !(wbuffer = VIPS_NEW( NULL, WriteBuffer )) )
return( NULL ); return( NULL );
wbuffer->write = write; wbuffer->write = write;
wbuffer->region = NULL; wbuffer->region = NULL;
vips_semaphore_init( &wbuffer->go, 0, "go" ); vips_semaphore_init( &wbuffer->go, 0, "go" );
vips_semaphore_init( &wbuffer->nwrite, 0, "nwrite" ); vips_semaphore_init( &wbuffer->nwrite, 0, "nwrite" );
vips_semaphore_init( &wbuffer->done, 0, "done" ); vips_semaphore_init( &wbuffer->done, 0, "done" );
vips_semaphore_init( &wbuffer->finish, 0, "finish" );
wbuffer->write_errno = 0; wbuffer->write_errno = 0;
wbuffer->thread = NULL; wbuffer->running = FALSE;
wbuffer->kill = FALSE; wbuffer->kill = FALSE;
if( !(wbuffer->region = vips_region_new( write->sink_base.im )) ) { if( !(wbuffer->region = vips_region_new( write->sink_base.im )) ) {
wbuffer_free( wbuffer ); wbuffer_free( wbuffer );
return( NULL ); return( NULL );
} }
/* The worker threads need to be able to move the buffers around. /* The worker threads need to be able to move the buffers around.
*/ */
vips__region_no_ownership( wbuffer->region ); vips__region_no_ownership( wbuffer->region );
/* Make this last (picks up parts of wbuffer on startup). /* Make this last (picks up parts of wbuffer on startup).
*/ */
if( !(wbuffer->thread = vips_g_thread_new( "wbuffer", if( vips__thread_execute( "wbuffer", wbuffer_write_thread,
wbuffer_write_thread, wbuffer )) ) { wbuffer ) ) {
wbuffer_free( wbuffer ); wbuffer_free( wbuffer );
return( NULL ); return( NULL );
} }
wbuffer->running = TRUE;
return( wbuffer ); return( wbuffer );
} }
/* Block until the previous write completes, then write the front buffer. /* Block until the previous write completes, then write the front buffer.
*/ */
static int static int
wbuffer_flush( Write *write ) wbuffer_flush( Write *write )
{ {
VIPS_DEBUG_MSG( "wbuffer_flush:\n" ); VIPS_DEBUG_MSG( "wbuffer_flush:\n" );
 End of changes. 12 change blocks. 
13 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)