• 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: Multithreading and memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading and memory management question


  • Subject: Re: Multithreading and memory management question
  • From: eveningnick eveningnick <email@hidden>
  • Date: Fri, 22 Apr 2011 01:10:48 +0300

Hi Ken,
> How are you spawning your threads?
> If you use Cocoa methods, then they automatically retain the object which is the target of the selector and the argument object for the life of the thread.  So, you may be getting this automatically without realizing it.  If not, then it should be easy to arrange.

thanks, i used cocoa methods but didn't know the object is being
retained. That simplifies the code how it looks :)

> If you're using some other technique to spawn your threads, you can just retain the object before spawning the thread and then have the thread work function or method release it before exiting.  The retain and the release don't have to occur on the same thread.

The problem i still have  - is the display link. It is a system
thread, that calls a method periodically. When i stop display link
(while the method is being executed)  - this execution of the method
will be the last, it won't be called anymore. As i described in the
first post, the object is being used from the display link callback. I
can't pass an object that comfortable, as i did with cocoa methods
(unfortunately). I can't retain an object before starting display link
as you suggested here - because i can't know when this "before
exiting" time happens - display link's thread is a CoreVideo
framework's thread, and it just calls my function repeatedly. I was
thinking about using some custom flag (like, BOOL
thisIsTheLastTimeTheDisplayLinkMethodIsBeingCalled) protected by a
critical section, and which is set when i stop "System high-priority
display link thread". But the solution would look very ad-hoc and
hardly readable, hardly maintainable when the amount of code grows. I
am wondering maybe there's a prettier way to do it.

Thanks
_______________________________________________

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

References: 
 >Multithreading and memory management question (From: eveningnick eveningnick <email@hidden>)
 >Re: Multithreading and memory management question (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Multithreading and memory management question
  • Next by Date: Re: CoreData: "Could not fulfill a fault", but only sometimes?
  • Previous by thread: Re: Multithreading and memory management question
  • Next by thread: Re: CoreData: "Could not fulfill a fault", but only sometimes?
  • Index(es):
    • Date
    • Thread