• 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: Thread-safe singleton with lazy initialisation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread-safe singleton with lazy initialisation


  • Subject: Re: Thread-safe singleton with lazy initialisation
  • From: Simone Tellini <email@hidden>
  • Date: Tue, 18 Aug 2015 18:18:37 +0200

Il giorno 18/ago/2015, alle ore 18:00, Maxthon Chan <email@hidden> ha scritto:
>
> So the first class that is required is the main application class CGIApplication. Being the analogue of UIApplication it is a singleton. Is this the proper way of doing it? I cannot use @synchronized yet because there is nothing to lock on:

if you used GCD, it would be simpler:

+ (instancetype)sharedInstance
{
	static dispatch_once_t once;
	static id ret;

	dispatch_once( &once, ^{
	        ret = [[self alloc] init];
	} );

	return ret;
}

--
Simone Tellini
http://tellini.info




_______________________________________________

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


  • Prev by Date: Re: Private Methods
  • Next by Date: Re: Private Methods
  • Previous by thread: Re: Xcode warning from linking to a third-party framework in both app and in framework included in app?
  • Next by thread: Re: Thread-safe singleton with lazy initialisation
  • Index(es):
    • Date
    • Thread