Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #84263

Re: A thread-queue

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Bo Persson <bo@bo-persson.se>
Newsgroups comp.lang.c++
Subject Re: A thread-queue
Date Thu, 26 May 2022 01:04:37 +0200
Lines 27
Message-ID <jf7r16FjldfU1@mid.individual.net> (permalink)
References <t6hekd$q6f$1@dont-email.me> <t6m592$vhd$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace individual.net eCUmNn4+xld82R2p16oaVQxqiG2eL374JF7dxMz68CkzHjwrEJ
Cancel-Lock sha1:ZezkSJ+vAmUMZFFW5LXFHwW5YOs=
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1
Content-Language sv
In-Reply-To <t6m592$vhd$1@dont-email.me>
Xref csiph.com comp.lang.c++:84263

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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