MUTEX_TRY_LOCK_FOR() will check whether the mutex->thread_holding equal to
this_thread() when in debug mode.

So, I think passing mutex->thread_holding will help us to do some check for
the code.

FYI.




On Mon, Apr 22, 2013 at 12:14 PM, 安静的风 <77009...@qq.com> wrote:

> Hi,
>
> Thanks in advanced.
>
> May I ask a question here?
>
>
>
> In a continuation's hanlder, take the code piece below for example,
>
> HostDBContinuation::dnsEvent {
>
> ...
>
> EThread *thread = mutex->thread_holding;    // here
>
> MUTEX_TRY_LOCK_FOR(lock, action.mutex, thread, action.continuation);
>
> ...
>
> }
>
> Why do we use mutex->thread_holding rather than this_ethread()?
>
> Is it due to the performance reason? pthread_getspecific is slow?
>
> I googled a lot, seems in x86/x64 Linux, there isn't too much cost. it
> just implemented with some special register, i.e. GS/FS.
>
> So, what's the reason?
>
>
>
> Thanks again,
>
> Xin




-- 
Yunkai Zhang
Work at Taobao

Reply via email to