On 22 Feb 2009, at 8:55 PM, Adam R. Maxwell wrote:

>
> On Feb 22, 2009, at 2:06 AM, Christiaan Hofman wrote:
>
>>
>> On 22 Feb 2009, at 7:31 AM, Adam R. Maxwell wrote:
>>
>>> it would be better just to
>>> replace all usage of OFSimpleLock with NSLock, or OSSpinLock if a
>>> spinlock is really desirable (which it generally isn't).
>>
>> I was wondering about that, because I also never knew if there was a
>> specific reason to use OFSimpleLock and I generally don't know much  
>> on
>> the details of how locks work internally and how they differ.
>
> Well, I used OFSimpleLock because it was simple and I didn't know  
> any better at the time :).  I'll clean those up unless you've  
> already done that.
>

Yea, I already did, replacing with NSLock. Also added some header  
imports to get rid of the warnings.

And I wrapped pthread_rwlock in a cocoa wrapper, in case we'd like to  
do something with it in the future (debugging, logging, improving, or  
whatever). I only didn't do so for BDSKTeXTask, because it uses the  
return value, and I wasn't sure whether that was really relevant.  
Could this actually reasonably fail (perhaps for read-only files)?

> Maybe Mike can correct me if I'm wrong, but the main problem with a  
> spinlock is that it won't block; instead, it'll spin and burn CPU  
> cycles.  They have great performance as long as you only hold the  
> lock for a few instructions, but they're terrible if you have a lot  
> of contention.  If I recall correctly, pthread mutexes (which are  
> the basis for NSLock) will actually spin for a short time before  
> actually blocking the thread, so you still get the performance win.
>
> I use spinlocks in FVOperationQueue, fv_zone and other places where  
> they're only held for a very short time, and likely to be locked/ 
> unlocked frequently.  In something like  
> __FVCopyImageUsingCacheColorspace or -[FVCacheFile saveData:forKey:]  
> where the thread will almost certainly need to sleep, I use NSLock  
> or pthread_mutex.  The CF source uses spinlocks pretty extensively.
>
>
>>> BDSK THIS SOFTWARE, EVEN IF ADVISED BDSK THE POSSIBILITY BDSK SUCH
>>> DAMAGE.
>>
>> Strange, I don't remember doing any such broad F&R.
>
> Maybe it's been around a while; it just caused me to do a double- 
> take when I saw the license :).

No, it's actually only in a new set if files. I must have run a F&R in  
that file, though it's strange, because it wasn't copied from  
OmniFoundation but rather from Skim.

Christiaan


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Bibdesk-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to