It is a digital art program where the user writes a description of an image and the program creates it. Image creation can be a lengthy process so I have the rendering thread periodically send a snapshot of what it has done so far to the view. This is purely to entertain the user while they wait for their image to finish.

What really happens is that the main thread has an NSTimer that tells it when to request an new snapshot. When this timer event fires the main thread sets a flag. The render thread checks this flag when it is at a good stopping point. When the render thread sees that the flag is set it send a message back to the main thread and waits for the message to complete. So the view is in control, it just needs to quiesce the rendering thread before it takes the snapshot.

-- john

On Sep 27, 2009, at 9:18 PM, Kyle Sluder wrote:

Overall your approach seems backwards.  Why is your render thread
telling your view when to draw itself?  The view should be in control
of when it is drawn.  This fits in with your scenario, which appears
to be a clear-cut example of the producer-consumer model.

--Kyle Sluder

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to