Re: Low-level equivalent of NSLock?
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.