But is this safe for accessing the ivars? While the ivar is read, I  
don't see why at the same time some other thread could change them,  
as the read-code is not inside a @synchronized block. (if I  
understand @synchronized correctly).

Christiaan

On 2 Jan 2008, at 9:29 PM, [EMAIL PROTECTED] wrote:

> Revision: 12203
>           http://bibdesk.svn.sourceforge.net/bibdesk/? 
> rev=12203&view=rev
> Author:   amaxwell
> Date:     2008-01-02 12:29:48 -0800 (Wed, 02 Jan 2008)
>
> Log Message:
> -----------
> create type manager in +initialize to get rid of @synchronized
>
> Modified Paths:
> --------------
>     trunk/bibdesk/BDSKTypeManager.m
>
> Modified: trunk/bibdesk/BDSKTypeManager.m
> ===================================================================
> --- trunk/bibdesk/BDSKTypeManager.m   2008-01-02 20:29:24 UTC (rev  
> 12202)
> +++ trunk/bibdesk/BDSKTypeManager.m   2008-01-02 20:29:48 UTC (rev  
> 12203)
> @@ -44,16 +44,19 @@
>
>  static BDSKTypeManager *sharedInstance = nil;
>
> -// note: if calling this in a loop, @synchronized() can be very  
> expensive, so call it before entering the loop
>  @implementation BDSKTypeManager
>  + (BDSKTypeManager *)sharedManager{
> -    @synchronized(sharedInstance){
> -        if(sharedInstance == nil)
> -            sharedInstance = [[BDSKTypeManager alloc] init];
> -    }
>      return sharedInstance;
>  }
>
> ++ (void)initialize
> +{
> +    OBINITIALIZE;
> +    // Create the singleton here since +initialize is thread safe;  
> @synchronized in +sharedManager was killing performance, especially  
> with the NSString category methods.
> +    if(sharedInstance == nil)
> +        sharedInstance = [[self alloc] init];
> +}
> +
>  - (id)init{
>      self = [super init];
>
>
>
> This was sent by the SourceForge.net collaborative development  
> platform, the world's largest Open Source development site.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to