I don't understand.  Part of the point is that you only have a reference to
the data (aPoint in this case) while it is also locked.

On Fri, Mar 22, 2019 at 10:16 AM Alan Carroll
<solidwallofc...@verizonmedia.com.invalid> wrote:

> I'd be more tempted to specialize `std::lock_guard` for the class. E.g. so
> that
>
> std::lock_guard lock{aPoint};
>
> works an RAII lock on `aPoint`. I think that makes it easier because
> there's only one thing the user has to remember, "lock_guard".
>
> On Fri, Mar 22, 2019 at 9:19 AM Walt Karas <wka...@verizonmedia.com
> .invalid>
> wrote:
>
> > scoped_lock is I think an alternative to lock_guard to avoid deadlock
> when
> > multiple mutexes must be locked at the same time.
> >
> > The point of the utility I propose is a fail-safe to make sure that
> > mutex-protected data is not accessed without locking the mutex, and
> clarity
> > about what data the mutex is protecting.
> >
> > On Thu, Mar 21, 2019 at 5:34 PM Jason Kenny <jke...@verizonmedia.com>
> > wrote:
> >
> > > I was thinking of https://en.cppreference.com/w/cpp/thread/scoped_lock
> > >
> > > Jason
> > >
> > > On Thu, Mar 21, 2019 at 4:53 PM Walt Karas <wka...@verizonmedia.com
> > .invalid>
> > > wrote:
> > >
> > >> What's the name of it in the Standard Lib?
> > >>
> > >> On Thu, Mar 21, 2019 at 4:45 PM Jason Kenny <jke...@verizonmedia.com
> > >> .invalid>
> > >> wrote:
> > >>
> > >> > I am unclear why it is needed. C++ 17 already has this in the std
> > >> library.
> > >> > these should be used instead of making our own
> > >> >
> > >> > Jason
> > >> >
> > >> > On Wed, Mar 20, 2019 at 4:17 PM Leif Hedstrom <zw...@apache.org>
> > wrote:
> > >> >
> > >> > > Don’t we have scoped mutexes already ?
> > >> > >
> > >> > > — Leif
> > >> > >
> > >> > > > On Mar 20, 2019, at 12:08, Walt Karas <wka...@verizonmedia.com
> > >> > .invalid>
> > >> > > wrote:
> > >> > > >
> > >> > > > https://godbolt.org/z/6klEJn
> > >> > > >
> > >> > > > Useful for mutex-protected objects, where the mutex is only
> locked
> > >> > within
> > >> > > > code blocks.  Could be used in this PR:
> > >> > > >
> > >> > > > https://github.com/apache/trafficserver/pull/5187
> > >> > >
> > >> > >
> > >> >
> > >>
> > >
> >
>

Reply via email to