Re: Threading - How its done?
Re: Threading - How its done?
- Subject: Re: Threading - How its done?
- From: Karl von Moller <email@hidden>
- Date: Wed, 7 May 2008 11:32:24 +1000
Awesome feedback! I couldn't find any info on this anywhere! At least
I can stop the search.
With regard to Threading PDF's, while I didn't want to specifically
build for 10.5 only, using NSOperation's or using some sort of
priority queue process - does this offer any protection for threading
PDF activities? As yet I have not used NSOperations but reading the
docs this sounds like it could encapsulate much of the Threading
detail for me.
taken from "Threading Programming Guide"
"One of the other great benefits of operation objects, though, is the
ability to add them to an operation queue. An operation queue manages
the execution of operation objects within separate threads of your
application. You do not have to write any thread creation or
management code to make this happen either. The operation queue takes
care of all the thread management work behind the scenes so that you
can focus on what you want to run, and not how you want to run it.
Operation queues can also manage interoperation dependencies to make
sure your tasks execute in the correct order."
Even though CFPDFDocumentRef etc are not thread safe would using
NSOperations to encapsulate them and manage their tasks in the
background work?
Cheers
Karl
On 07/05/2008, at 10:43 AM, John Calhoun wrote:
On May 6, 2008, at 4:51 PM, Karl von Moller wrote:
Does anyone know whether there is a way to get progress info from a
PDF loading into a view - percentage/bytes loaded for example?
No, I can think of no way to do this.
Be careful with threading and PDF... PDFKit classes are ultimately
based on CFPDFDocumentRef and CGPDFPageRef — these are not thread
safe. You cannot for example search for text in a PDFDocument while
rendering a PDFPage from that same PDFDocument. Or even render two
different PDFPages from the PDFDocument.
You can however have several CGPDFDocumwentRefs that point to the
same underlying file/data working on separate threads. You want
separate PDFDocument objects though:
PDFDocument *mainPDFDocument = [[PDFDocument alloc] initWithUR:
someURL];
PDFDocument *threadPDFDocument = [[PDFDocument alloc] initWithUR:
someURL];
Note, same URL, different PDFDocument instance.
John Calhoun
_______________________________________________
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