Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #84263
| From | Bo Persson <bo@bo-persson.se> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: A thread-queue |
| Date | 2022-05-26 01:04 +0200 |
| Message-ID | <jf7r16FjldfU1@mid.individual.net> (permalink) |
| References | <t6hekd$q6f$1@dont-email.me> <t6m592$vhd$1@dont-email.me> |
On 2022-05-25 at 22:58, Chris M. Thomasson wrote:
> On 5/23/2022 7:07 PM, Bonita Montero wrote:
>> This is a thread-queue I've written:
> [...]
>> template<typename QueueType>
>> requires thread_queue_concept<QueueType>
>> thread_queue<QueueType>
>> &thread_queue<QueueType>::thread_queue::operator =( thread_queue const
>> &other )
>> {
>> std::lock_guard
>> ourLock( m_mtx ),
>> otherLock( other.m_mtx );
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> This is a little scary. lock ordering issues come to mind. Fwiw, this is
> why I created multimutex:
>
> https://groups.google.com/g/comp.lang.c++/c/sV4WC_cBb9Q/m/5JRwvhpVCAAJ
>
The standard library version is scoped_lock that should handle lock ordering
std::scoped_lock locks(m_mtx, other.m_mtx);
https://en.cppreference.com/w/cpp/thread/scoped_lock
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-24 04:07 +0200
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-25 13:58 -0700
Re: A thread-queue Bo Persson <bo@bo-persson.se> - 2022-05-26 01:04 +0200
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-25 20:58 -0700
Re: A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-26 16:20 +0200
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-26 22:40 -0700
Re: A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-27 11:33 +0200
Re: A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-27 14:26 +0200
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-27 14:18 -0700
Re: A thread-queue scott@slp53.sl.home (Scott Lurndal) - 2022-05-27 21:53 +0000
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-27 15:43 -0700
Re: A thread-queue scott@slp53.sl.home (Scott Lurndal) - 2022-05-28 14:51 +0000
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-27 18:24 -0700
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-27 18:26 -0700
Re: A thread-queue scott@slp53.sl.home (Scott Lurndal) - 2022-05-28 14:56 +0000
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-28 16:49 -0700
Re: A thread-queue red floyd <no.spam.here@its.invalid> - 2022-05-28 17:16 -0700
Re: A thread-queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-30 16:00 -0700
Re: A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-28 07:16 +0200
Re: A thread-queue Bonita Montero <Bonita.Montero@gmail.com> - 2022-05-26 16:15 +0200
csiph-web