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 <[email protected]> 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 <[email protected]> > wrote: > >> What's the name of it in the Standard Lib? >> >> On Thu, Mar 21, 2019 at 4:45 PM Jason Kenny <[email protected] >> .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 <[email protected]> wrote: >> > >> > > Don’t we have scoped mutexes already ? >> > > >> > > — Leif >> > > >> > > > On Mar 20, 2019, at 12:08, Walt Karas <[email protected] >> > .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 >> > > >> > > >> > >> >
