• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Threaded drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threaded drawing


  • Subject: Re: Threaded drawing
  • From: Roland King <email@hidden>
  • Date: Sat, 07 Dec 2013 08:05:27 +0800

On 7 Dec, 2013, at 12:46 am, Graham Cox <email@hidden> wrote:

>
>
> 					@synchronized( self )
> 					{
> 						CGContextDrawImage( ctx, tileRect, tileImage );
> 					}
> 					CGImageRelease( tileImage );
>
> 					free( bitsPtr );
> 				}];
>
> 				[mDrawingQueue addOperation:op];
> #else
> 				[self drawTile:tileRect inContext:ctx];
> #endif
>
> 			}
> 		}
> 	}
>
> #if DRAW_THREADED
> 	[mDrawingQueue waitUntilAllOperationsAreFinished];
> #endif
>

You could also, instead of synchronizing the CGContextDrawImage(), which may make your threads wait for each other for some infinitessimal time, use

dispatch_async( dispatch_get_main_queue(), {
	CGContextDrawImage( ctx, tileRect, tileImage );
	CGImageRelease( tileImage );
	free( bitsPtr );
}

which serializes them. And I doubt it would make a sod of difference.

For completeness, if you wanted a dispatch queue as opposed to NSOperationQueue based approach, setting up a dispatch queue, concurrent one, and using dispatch_apply() with iterations = tx * ty would do that, and wait for completion, so you don't need the waitUntilAllOperationsAreFinished.  But that's just preference, I use dispatch queues when I can most of the time.

And reminded of the comment about how hard block syntax can be to remember, I didn't make this page, I'm not a fan of the name, but it's awfully useful and I keep it bookmarked,  I tinyURLed it to avoid tripping up swear checkers, http://tinyurl.com/m6lukyg.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Threaded drawing
      • From: Graham Cox <email@hidden>
    • Re: Threaded drawing
      • From: Ken Thomases <email@hidden>
References: 
 >Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: Roland King <email@hidden>)
 >Re: Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: Roland King <email@hidden>)
 >Re: Threaded drawing (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Threaded drawing
  • Next by Date: Re: Threaded drawing
  • Previous by thread: Re: Threaded drawing
  • Next by thread: Re: Threaded drawing
  • Index(es):
    • Date
    • Thread