Re: drawing NOW in a callback, boom!
Re: drawing NOW in a callback, boom!
- Subject: Re: drawing NOW in a callback, boom!
- From: Aram Greenman <email@hidden>
- Date: Wed, 5 Jun 2002 00:02:17 -0700
On Tuesday, June 4, 2002, at 06:15 PM, Paul Cezanne wrote:
Now, just to make life harder, I'm not using NSThread, I'm using
pthreads
From Cocoa Topics: Mulithreading:
"NSThreads are built upon POSIX threads (pthreads).
You can create your own pthreads, but some Cocoa classes, such as
NSAutoreleasePool, expect to be running within an NSThread and may not
work properly in a pthread.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Creating a pthread does not notify Cocoa classes that the application
has become multithreaded, so the NSThread method isMultiThreaded may
return NO. If you need access to the pthread within an NSThread, call
the pthread_self function from within that thread."
....
"In a multithreaded application, the main thread is still responsible
for redisplaying dirty views through the same process as a
single-threaded application. The drawRect: method of every dirty view is
called in the main thread.
If the drawing needs to be done in another thread, the drawRect: method
for the view should arrange for the secondary thread to do the drawing
and not do any drawing in drawRect:."
I call display, not setNeedsDisplay, because when this callback returns
the thread expects the screen to have the new color painted on it right
then and there.
ibid.:
"An explicit call to the NSView method display on a secondary thread
will be treated as if it were a call to setNeedsDisplay: with an
argument of YES, and the display will be done on the main thread."
Aram
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.