• 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: Two threads two autorelease pools one object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two threads two autorelease pools one object?


  • Subject: Re: Two threads two autorelease pools one object?
  • From: Joseph Kelly <email@hidden>
  • Date: Wed, 2 Nov 2005 18:31:54 -0800


On Nov 2, 2005, at 1:50 PM, John C. Randolph wrote:


On Nov 2, 2005, at 12:57 PM, Brian O'Brien wrote:


 is it possible that the instance of the object exists
in two auto-release pools at the same time


This is a red herring. Threaded or not, you just have to take care to balance -retain and -release messages.


Objects don't "exist in auto-release pools", they exist in memory. An Autorelease pool is nothing more than a delayed message mechanism. Autorelease pools don't free objects, either. They send objects a -release message, and the object itself decides whether it's time to -dealloc.


Even if you have proper memory management, you are not at all guaranteed this will work in a multithreaded environment (e.g. you grab an object in one thread and are about retain it, when it gets released in another thread).


So you need some strategies for thread safety (lots about this on cocoadev.com): e.g. if you have methods on a class that may be called by many threads and which manipulate data stored in that object, you must have some kind of synchronization in place (NSLock or whatever).

joe
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Two threads two autorelease pools one object? (From: "Brian O'Brien" <email@hidden>)
 >Re: Two threads two autorelease pools one object? (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: setPrimitiveValue:forKey: question
  • Next by Date: Re: setPrimitiveValue:forKey: question
  • Previous by thread: Re: Two threads two autorelease pools one object?
  • Next by thread: -refreshObject:mergeChanges: - need more transient property flexibility
  • Index(es):
    • Date
    • Thread