The @synchronized in the singleton setup is just to prevent a race condition 
when it's first created.  I think only the accessors that are used from another 
thread have to be @synchronized, in conjunction with the methods that modify 
the variables used from multiple threads.  localFileFieldsSet has an 
@synchronized in it for the file content indexing, but I just realized that's 
no longer used.  We may be able to get rid of all the locks.

On Wednesday, January 02, 2008, at 12:37PM, "Christiaan Hofman" <[EMAIL 
PROTECTED]> wrote:
>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
>
>

-------------------------------------------------------------------------
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