• 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: Automagic instantiation of singletons? (Christian Brunschen)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automagic instantiation of singletons? (Christian Brunschen)


  • Subject: Re: Automagic instantiation of singletons? (Christian Brunschen)
  • From: Scott Ribe <email@hidden>
  • Date: Sat, 19 Nov 2005 07:44:14 -0700
  • Thread-topic: Automagic instantiation of singletons? (Christian Brunschen)

> The common way in C++ for instantiating singletons is

That's a lousy way to do it in C++, because you have no portable and
reliable way to control the order of instantiation, so you have to make
*sure* that there is *no* dependency anywhere between any 2 singletons,
otherwise you have a situation where even just a minor version bump of your
current tools can create a hard crash.

It's even worse in Objective-C++, since the C++ statics may be constructed
before the Cocoa runtime is completely up, and may be destructed after it is
at least partially torn down. I'm not clear on the specifics of that, but I
can tell you that using this idiom with C++ classes that interact with Cocoa
objects can lead to hard to track down crashes during application exit. It
may work perfectly well now, but there's no guarantee that it will continue
to work.

--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 665-7007 voice


 _______________________________________________
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: 
 >Re: Automagic instantiation of singletons? (Christian Brunschen) (From: Theo Vosse <email@hidden>)

  • Prev by Date: Drag&Drop to selected NSTextField?
  • Next by Date: Embedding custom attachment cell in a NSTextView
  • Previous by thread: Re: Automagic instantiation of singletons? (Christian Brunschen)
  • Next by thread: Asynchronous Methods Question
  • Index(es):
    • Date
    • Thread