• 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: multithreaded PDF Rendering
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multithreaded PDF Rendering


  • Subject: Re: multithreaded PDF Rendering
  • From: Andrei IDS <email@hidden>
  • Date: Tue, 15 Jan 2002 19:15:44 +0200

Hi Jerome,

I think you will need to detach new thread and change it's priority.
Unfortunately NSThread does not provide a method for this (I hope Apple is
working hard on this and never posted a feature request for it - just
kidding). But all you need is to include the following code in the new
thread:

//declarations of PTHREAD variables
pthread_t tid;
int ret;
struct sched_param param;
int lowPriority;
int policy;

//and the code
lowPriority = 10; //this will be the new priority, the lowest is 0.

tid = pthread_self(); //takes it's own thread id
ret = pthread_getschedparam(tid, &policy, &param); //reads it's own thread
variables into scheduling parameters structure 'param'
policy = SCHED_OTHER;
param.sched_priority = lowPriority; //changes the value of the priority
ret = pthread_setschedparam(tid, policy, &param); //and applies it to the
current thread

This should work, HOWEVER I am afraid it will not work efficiently if you do
not have enough RAM (if your NSPDFImageRep needs a lot of memory to render
the PDF the OS will swap memory back and forth when switching between
threads - at least I think it will do so).

Best Regards,
Andrei


> I actually use NSPDFImageRep to render PDF and everything works fine.
> However, very complex pdf files may cause slow machines (like mine)
> to stop the handling of the user interface for a long time.
> So i tried to render the pdf representation using another thread,
> i also used a detached drawing thread but all that does not make no
> differece to me:
> i still cannot use the UI while some PDF is rendering.
>
> As i am not familiar with multithreading, i might have missed something
> very important.
> Any hints on how to achieve this?
>
> TIA


  • Prev by Date: Odd Toolbar Behavior
  • Next by Date: Re: Newbie: NSGlyph <-> unicode ?
  • Previous by thread: multithreaded PDF Rendering
  • Next by thread: Re: multithreaded PDF Rendering
  • Index(es):
    • Date
    • Thread