[ 
https://issues.apache.org/jira/browse/TS-3156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14205749#comment-14205749
 ] 

Powell Molleti commented on TS-3156:
------------------------------------

Hi Alan,

It does take ownership of the object since the api says:

class MutexLock
{
private:
  Ptr<ProxyMutex> m;
public:
  MutexLock(ProxyMutex * am, EThread * t):m(am)
};

It is perfectly ok from compiler perspective  to use it as follows:

ProxyMutex foo;
{
   MutexLock(lock, &foo, this_ethread()); <-- takes lock and smart pointer 
owners it with ref count 1
} <-- lock object is destroyed and since smart pointer has ref count of zero 
when dying it will free ProxyMutex;

The constructor should be MutexLock(Ptr<ProxyMutex> m, EThread * t);
and the call should be enforced as MutexLock(lock, Ptr<ProxyMutex>(&foo), 
this_ethread()); to force auto refcount up.

Let me know.
Powell




> Mutex[Try]Lock bool() operator change and unused API removal
> ------------------------------------------------------------
>
>                 Key: TS-3156
>                 URL: https://issues.apache.org/jira/browse/TS-3156
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Powell Molleti
>            Assignee: James Peach
>            Priority: Minor
>              Labels: review
>             Fix For: 5.2.0
>
>         Attachments: MutexLock-ats.patch, MutexLock-ats.patch, 
> Use-Ryo-s-patch-to-pass-shared_ptr-to-MutexLock.patch, fix-MutexLock.patch
>
>
> Removed unused constructor in MutexLock along with set_and_take() method, had 
> to change FORCE_PLUGIN_MUTEX() for that. Removed release() method.
> default bool and ! operator from both MutexLock and MutexTryLock with 
> is_locked() API. Changes if (lock) to if (lock.is_locked()) across the code 
> base.
> Ran make test will be performing more system testing. Posted before for early 
> comments / feedback.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to