• 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: Programatically detect if any autorelease pool exists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programatically detect if any autorelease pool exists?


  • Subject: Re: Programatically detect if any autorelease pool exists?
  • From: John Stiles <email@hidden>
  • Date: Tue, 5 Sep 2006 17:16:15 -0700

On Sep 5, 2006, at 5:01 PM, Chris Suter wrote:

It will help if you have a C++ class which manages the autorelease pools by automatically releasing it when it goes out of scope. Then it becomes a little less wordy:

class Stuff
{
public:
Stuff()
{
AutoNSAutoreleasePool pool;
do stuff
m_importantThing = [[ImportantThing importantThingWithWhatever: 0] retain];
}
void Fn()
{
AutoNSAutoreleasePool pool;
[m_importantThing useIt];
}
~Stuff()
{
AutoNSAutoreleasePool pool;
do stuff
[m_importantThing release];
}
protected:
ImportantThing * m_importantThing;
}

I'm not sure how Objective C exceptions work with Objective C++, but there's a chance this would break them if you needed them.

Indeed, mixing two languages' exception handling mechanisms at once is a sure-fire recipe for disaster.
Personally I avoid using most types of exception handers in my own code, so I didn't consider this, and don't know the solution. It's possible that there is no good solution if you want two types of exception handling to peacefully coexist.




_______________________________________________
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


  • Follow-Ups:
    • Re: Programatically detect if any autorelease pool exists?
      • From: Chris Suter <email@hidden>
References: 
 >Programatically detect if any autorelease pool exists? (From: "Sean McBride" <email@hidden>)
 >Re: Programatically detect if any autorelease pool exists? (From: "Clark Cox" <email@hidden>)
 >Re: Programatically detect if any autorelease pool exists? (From: "Sean McBride" <email@hidden>)
 >Re: Programatically detect if any autorelease pool exists? (From: John Stiles <email@hidden>)
 >Re: Programatically detect if any autorelease pool exists? (From: Chris Suter <email@hidden>)

  • Prev by Date: Re: Is it possible that PreferencePane's share "classes name space"?
  • Next by Date: building a predicate for empty optional to-many relationship
  • Previous by thread: Re: Programatically detect if any autorelease pool exists?
  • Next by thread: Re: Programatically detect if any autorelease pool exists?
  • Index(es):
    • Date
    • Thread