Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Professional wrestling: ballet for the common man.


devel / comp.lang.c++ / Re: Why is there lock_guard ?

SubjectAuthor
* Why is there lock_guard ?Bonita Montero
+* Re: Why is there lock_guard ?Chris M. Thomasson
|`* Re: Why is there lock_guard ?Bonita Montero
| `* Re: Why is there lock_guard ?Chris M. Thomasson
|  `* Re: Why is there lock_guard ?Bonita Montero
|   `- Re: Why is there lock_guard ?Chris M. Thomasson
`* Re: Why is there lock_guard ?Andrey Tarasevich
 `- Re: Why is there lock_guard ?Bonita Montero

1
Why is there lock_guard ?

<uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3164&group=comp.lang.c%2B%2B#3164

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Why is there lock_guard ?
Date: Sat, 17 Feb 2024 20:15:33 +0100
Organization: A noiseless patient Spider
Lines: 2
Message-ID: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 17 Feb 2024 19:15:34 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="e25f48bc57ca64a8df9ad12f8a5fa758";
logging-data="599365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xzTbkypf69JWGn/kDc164lPmhG3rFPBw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:XK8+ot0/sONYdACESRRwr+WdeXg=
Content-Language: de-DE
 by: Bonita Montero - Sat, 17 Feb 2024 19:15 UTC

Why is there lock_guard when unique_lock can anything lock_guard
can do but far more ?

Re: Why is there lock_guard ?

<uqrg50$l697$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3165&group=comp.lang.c%2B%2B#3165

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Sat, 17 Feb 2024 15:40:15 -0800
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uqrg50$l697$2@dont-email.me>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 17 Feb 2024 23:40:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1e508b2a4bbf8942f78618e5f282635e";
logging-data="694567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hFOmZp9V3jRhPB/6Ie5LMLnV23zb+pbI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:xUNv9rdtV0GUSKyOroX/g4sEEAQ=
In-Reply-To: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
Content-Language: en-US
 by: Chris M. Thomasson - Sat, 17 Feb 2024 23:40 UTC

On 2/17/2024 11:15 AM, Bonita Montero wrote:
> Why is there lock_guard when unique_lock can anything lock_guard
> can do but far more ?

lock_guard is meant for its purpose. Only use unique_lock when you need
to. And be careful, you can shoot yourself in the foot with it...

Re: Why is there lock_guard ?

<uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3166&group=comp.lang.c%2B%2B#3166

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Sun, 18 Feb 2024 07:59:10 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
<uqrg50$l697$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Feb 2024 06:59:10 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="31050746877aebf046e73bd0ef7ec6b8";
logging-data="991950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r1nVzTB8tX1/ee9eWwCJyak8CSW/HCAg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:iPV9brNBwixuIkohz4N2wZ5C9c8=
In-Reply-To: <uqrg50$l697$2@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sun, 18 Feb 2024 06:59 UTC

Am 18.02.2024 um 00:40 schrieb Chris M. Thomasson:
> On 2/17/2024 11:15 AM, Bonita Montero wrote:
>> Why is there lock_guard when unique_lock can anything lock_guard
>> can do but far more ?
>
> lock_guard is meant for its purpose. ...

You easily could do ...

template<typename Lock>
using std::lock_guard = std::unique_lock<Lock>;

.... without any problems.

For me lock_guard doesn't make sense.

Re: Why is there lock_guard ?

<uqtod6$1e3t2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3167&group=comp.lang.c%2B%2B#3167

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Sun, 18 Feb 2024 12:13:26 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uqtod6$1e3t2$1@dont-email.me>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
<uqrg50$l697$2@dont-email.me>
<uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 18 Feb 2024 20:13:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1e508b2a4bbf8942f78618e5f282635e";
logging-data="1511330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XMag2G/yo1qHI7MzDTr5vB4+2+90OtQ4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:GIMON6xV005fbQpek9BcDb38yQ0=
Content-Language: en-US
In-Reply-To: <uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>
 by: Chris M. Thomasson - Sun, 18 Feb 2024 20:13 UTC

On 2/17/2024 10:59 PM, Bonita Montero wrote:
> Am 18.02.2024 um 00:40 schrieb Chris M. Thomasson:
>> On 2/17/2024 11:15 AM, Bonita Montero wrote:
>>> Why is there lock_guard when unique_lock can anything lock_guard
>>> can do but far more ?
>>
>> lock_guard is meant for its purpose. ...
>
> You easily could do ...
>
>     template<typename Lock>
>     using std::lock_guard = std::unique_lock<Lock>;
>
> ... without any problems.
>
> For me lock_guard doesn't make sense.

It has its purpose. If you did this then std::lock_guard would be
moveable even though its not meant to be. That's just one point...

Re: Why is there lock_guard ?

<uquq7e$1npf7$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3168&group=comp.lang.c%2B%2B#3168

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Mon, 19 Feb 2024 06:50:38 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uquq7e$1npf7$1@raubtier-asyl.eternal-september.org>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
<uqrg50$l697$2@dont-email.me>
<uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>
<uqtod6$1e3t2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 05:50:38 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="a005c1d519b0ab5209fef09d194e21c1";
logging-data="1828327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7h1vUTNXs04yyGGEL4eh1oVo/guv+Qg8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:F9mcq0BbSip/DYfHy3V340+QrPA=
In-Reply-To: <uqtod6$1e3t2$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Mon, 19 Feb 2024 05:50 UTC

Am 18.02.2024 um 21:13 schrieb Chris M. Thomasson:
> On 2/17/2024 10:59 PM, Bonita Montero wrote:
>> Am 18.02.2024 um 00:40 schrieb Chris M. Thomasson:
>>> On 2/17/2024 11:15 AM, Bonita Montero wrote:
>>>> Why is there lock_guard when unique_lock can anything lock_guard
>>>> can do but far more ?
>>>
>>> lock_guard is meant for its purpose. ...
>>
>> You easily could do ...
>>
>>      template<typename Lock>
>>      using std::lock_guard = std::unique_lock<Lock>;
>>
>> ... without any problems.
>>
>> For me lock_guard doesn't make sense.
>
> It has its purpose. ...

.... which unique_lock also fulfills.

Re: Why is there lock_guard ?

<ur0bpj$21st3$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3169&group=comp.lang.c%2B%2B#3169

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Mon, 19 Feb 2024 11:56:34 -0800
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ur0bpj$21st3$1@dont-email.me>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
<uqrg50$l697$2@dont-email.me>
<uqs9ru$u8me$1@raubtier-asyl.eternal-september.org>
<uqtod6$1e3t2$1@dont-email.me>
<uquq7e$1npf7$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 19 Feb 2024 19:56:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5d14c860d25f9609127657841fafa775";
logging-data="2159523"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3a6GSDU+lG2dgkY7Lxh5yq3SqPr+hl3c="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:m7dSUTq5HOhfSRXCpdllmFJyIqg=
In-Reply-To: <uquq7e$1npf7$1@raubtier-asyl.eternal-september.org>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 19 Feb 2024 19:56 UTC

On 2/18/2024 9:50 PM, Bonita Montero wrote:
> Am 18.02.2024 um 21:13 schrieb Chris M. Thomasson:
>> On 2/17/2024 10:59 PM, Bonita Montero wrote:
>>> Am 18.02.2024 um 00:40 schrieb Chris M. Thomasson:
>>>> On 2/17/2024 11:15 AM, Bonita Montero wrote:
>>>>> Why is there lock_guard when unique_lock can anything lock_guard
>>>>> can do but far more ?
>>>>
>>>> lock_guard is meant for its purpose. ...
>>>
>>> You easily could do ...
>>>
>>>      template<typename Lock>
>>>      using std::lock_guard = std::unique_lock<Lock>;
>>>
>>> ... without any problems.
>>>
>>> For me lock_guard doesn't make sense.
>>
>> It has its purpose. ...
>
> ... which unique_lock also fulfills.
>
>

lock_guard is highly restricted when compared to unique_lock... ;^)

Re: Why is there lock_guard ?

<urrmr8$12lh0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3175&group=comp.lang.c%2B%2B#3175

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreytarasevich@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Thu, 29 Feb 2024 20:50:47 -0800
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <urrmr8$12lh0$1@dont-email.me>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 04:50:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d080a32c13fb972ac462368775d2b18c";
logging-data="1136160"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L4Ab1KTouT30ojZz/l95Z"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zTS1vLZ4MAGuIYV2WZ+fp/sReec=
Content-Language: en-US
In-Reply-To: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
 by: Andrey Tarasevich - Fri, 1 Mar 2024 04:50 UTC

On 02/17/24 11:15 AM, Bonita Montero wrote:
> Why is there lock_guard when unique_lock can anything lock_guard
> can do but far more ?

If you really want to ask about it, you should probably consider
`scoped_lock` instead of `lock_guard` anyway. The rest can be found here

https://stackoverflow.com/a/60172828

--
Best regards,
Andrey

Re: Why is there lock_guard ?

<ursmci$18q22$1@raubtier-asyl.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3176&group=comp.lang.c%2B%2B#3176

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Why is there lock_guard ?
Date: Fri, 1 Mar 2024 14:49:13 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ursmci$18q22$1@raubtier-asyl.eternal-september.org>
References: <uqr0kl$i9a5$1@raubtier-asyl.eternal-september.org>
<urrmr8$12lh0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Mar 2024 13:49:07 -0000 (UTC)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="562ca5826301ca46c61678f52578b195";
logging-data="1337410"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MoQUze5/YCgTOLiT2sdv7m/kWxycytoc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HD0TPiHNsWK9S5W43avEUtBLnYo=
In-Reply-To: <urrmr8$12lh0$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Fri, 1 Mar 2024 13:49 UTC

Am 01.03.2024 um 05:50 schrieb Andrey Tarasevich:
> On 02/17/24 11:15 AM, Bonita Montero wrote:
>> Why is there lock_guard when unique_lock can anything lock_guard
>> can do but far more ?
>
> If you really want to ask about it, you should probably consider
> `scoped_lock` instead of `lock_guard` anyway. The rest can be found here

scoped_lock is only necessary if you need to lock multiple mutexes. The
mutexes are internally sorted according to their addresses, resulting in
no deadlocks as long as all competing threads do it the same way. You
can not defer locking or adopt already locked mutexes with scoped_lock,
so there's something essentially missing with scoped_lock.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor