Re: Custom data formatter for pthread_mutex_t?
Re: Custom data formatter for pthread_mutex_t?
- Subject: Re: Custom data formatter for pthread_mutex_t?
- From: Steve Checkoway <email@hidden>
- Date: Fri, 17 Aug 2007 04:18:53 -0700
On Aug 17, 2007, at 3:16 AM, Alastair Houghton wrote:
On 17 Aug 2007, at 08:40, Steve Checkoway wrote:
If the mutex is nonrecursive (which, by the way, would break the
example function written earlier, I believe),
Why do you suppose that? A non-recursive mutex would return EBUSY
if it's already locked, just as if it was locked from another thread.
It *is* true that it could provide an unexpected result for a
*recursive* mutex, since it would indicate that it wasn't locked if
the thread holding the mutex happened to be the thread that called
the function (because pthread_mutex_trylock() would succeed in that
case). But IMO recursive mutexes are best avoided (they increase
the risk that you will write code that acquires locks in the wrong
order, and that you won't notice because in some code paths it will
work...)
That's what I was saying. If it's called from the same thread, it'll
report that it isn't locked when, in fact, it is.
--
Steve Checkoway
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden