• 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: Low-level equivalent of NSLock?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Low-level equivalent of NSLock?


  • Subject: Re: Low-level equivalent of NSLock?
  • From: Pierre-Olivier Latour <email@hidden>
  • Date: Thu, 14 Nov 2002 12:06:54 -0800

> I think it's a wrapper for pthread_mutex_* (and NSConditionalLock is a
> wrapper for pthread_cond_*).
>
> Have you done any measurements of NSLock performance (especially in the
> context of your app) to determine that it's a performance problem? It
> doesn't seem to do all that much more than call pthread.

No, I've not done any measurements, but I will need locks with timeouts in a
critical part of my program which runs at more than 1Khz. And this part will
be in C, not Obj-C, I forgot to say. So the lighter the better.

To me, this Cocoa code has to be slower than a simple call to a low-level
routine i.e. Something like MutexLockBeforeTime(myMutex, 5000 ms);

pool = [[NSAutoReleasePool alloc] init]
[lock lockBeforeDate:[NSDate xxx]];
[pool release];

I've looked into phthread.h, and it seems that what I need is here, but I
haven't figured out how to have a "lockBeforeTime" behavior with the mutex.
It's clear you have to use "pthread_cond_timedwait()", but I don't
understand what's this "pthread_cond_t" param and how to use it.

If someone could tell me how to lock the mutex with a timeout of x ms, that
would be nice :)

Thanks!

_____________________________________________________________

Pierre-Olivier Latour email@hidden
Palo Alto, USA http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Low-level equivalent of NSLock? (From: Lindsey Spratt <email@hidden>)

  • Prev by Date: Attaching a menu to a view
  • Next by Date: UndoManager
  • Previous by thread: Re: Low-level equivalent of NSLock?
  • Next by thread: Re: Main Menu Duplication Feature
  • Index(es):
    • Date
    • Thread