Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #84264
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: A thread-queue |
| Date | 2022-05-25 20:58 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <t6mtt6$bmd$1@dont-email.me> (permalink) |
| References | <t6hekd$q6f$1@dont-email.me> <t6m592$vhd$1@dont-email.me> <jf7r16FjldfU1@mid.individual.net> |
On 5/25/2022 4:04 PM, Bo Persson wrote:
> 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
Ahhh, I have never used it before. Thanks for the heads up Bo. I see
that it uses the traditional try_lock method. The multimutex I did
simply hashes pointers into an index of a table of locks; sorts and
removes duplicates of the resulting indexes; and takes the locks. The
sorting always avoids deadlock. I remove duplicates in order to get
around having to use recursive locks.
..
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