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


Groups > comp.lang.c++ > #88973 > unrolled thread

Found a use case for `const` by value return, a shared queue

Started by"Alf P. Steinbach" <alf.p.steinbach@gmail.com>
First post2023-02-04 22:32 +0100
Last post2023-03-07 17:37 +0100
Articles 10 on this page of 70 — 14 participants

Back to article view | Back to comp.lang.c++


Contents

  Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-04 22:32 +0100
    Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-05 15:37 +0100
      Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-05 22:45 +0100
    Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-05 12:49 -0800
      Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-05 22:39 +0100
        Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-06 22:09 +0100
          Re: Found a use case for `const` by value return, a shared queue scott@slp53.sl.home (Scott Lurndal) - 2023-02-06 21:35 +0000
            Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-06 23:44 +0100
              Re: Found a use case for `const` by value return, a shared queue scott@slp53.sl.home (Scott Lurndal) - 2023-02-07 01:34 +0000
              Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-07 07:42 -0800
                Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-07 17:34 +0100
                  Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-24 07:51 -0800
                    Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-24 18:48 +0100
                      Re: Found a use case for `const` by value return, a shared queue Daniel <danielaparker@gmail.com> - 2023-02-26 09:50 -0800
                        Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-05 08:38 -0800
                      Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-05 08:43 -0800
                        Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-06 15:51 +0100
                Re: Found a use case for `const` by value return, a shared queue scott@slp53.sl.home (Scott Lurndal) - 2023-02-07 16:35 +0000
                  Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-22 06:28 -0800
                    Re: Found a use case for `const` by value return, a shared queue scott@slp53.sl.home (Scott Lurndal) - 2023-02-22 15:01 +0000
                      Re: Found a use case for `const` by value return, a shared queue Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-02-24 08:34 -0800
            Re: Found a use case for `const` by value return, a shared queue Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-07 01:02 +0200
              Re: Found a use case for `const` by value return, a shared queue scott@slp53.sl.home (Scott Lurndal) - 2023-02-07 01:27 +0000
                Re: Found a use case for `const` by value return, a shared queue Paavo Helde <eesnimi@osa.pri.ee> - 2023-02-07 08:55 +0200
                  Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-02-07 12:11 -0800
            Re: Found a use case for `const` by value return, a shared queue James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-02-07 00:19 -0500
              Re: Found a use case for `const` by value return, a shared queue Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-06 21:41 -0800
              Re: Found a use case for `const` by value return, a shared queue Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-02-08 16:49 +0000
                Re: Found a use case for `const` by value return, a shared queue red floyd <no.spam.here@its.invalid> - 2023-02-08 11:11 -0800
                  Re: Found a use case for `const` by value return, a shared queue Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-02-09 00:40 +0000
                    Re: Found a use case for `const` by value return, a shared queue Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-02-08 17:15 -0800
                      Re: Found a use case for `const` by value return, a shared queue Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-02-09 03:07 +0000
                        Re: Found a use case for `const` by value return, a shared queue "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-02-09 04:54 +0100
                          Re: Found a use case for `const` by value return, a shared queue Öö Tiib <ootiib@hot.ee> - 2023-02-08 23:38 -0800
                            Re: Found a use case for `const` by value return, a shared queue David Brown <david.brown@hesbynett.no> - 2023-02-09 09:10 +0100
    Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-03 19:51 +0100
      Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-03 12:45 -0800
        Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 05:38 +0100
          Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-04 15:25 -0800
            Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-05 05:19 +0100
              Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-05 13:41 -0800
                Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-06 16:11 +0100
      Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-04 09:53 +0000
        Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 15:38 +0100
          Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-04 15:28 +0000
            Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 17:17 +0100
              Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-04 16:21 +0000
                Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 17:39 +0100
                  Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-04 16:57 +0000
                    Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 18:06 +0100
                      Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 18:10 +0100
                      Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-04 17:14 +0000
                        Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 18:41 +0100
                          Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-04 20:07 +0100
                            Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-04 15:26 -0800
                              Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-05 05:18 +0100
                                Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-05 13:37 -0800
                                  Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-06 05:52 +0100
                                    Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-06 15:29 -0800
                                    Re: Found a use case for `const` by value return, a shared queue "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-03-06 15:42 -0800
                          Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-06 09:18 +0000
                            Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-06 11:18 +0100
                              Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-06 10:26 +0000
                                Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-06 16:10 +0100
                                  Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-06 17:07 +0000
                                    Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-07 06:44 +0100
                                      Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-07 09:31 +0000
                                        Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-07 14:45 +0100
                                          Re: Found a use case for `const` by value return, a shared queue Muttley@dastardlyhq.com - 2023-03-07 15:59 +0000
                                            Re: Found a use case for `const` by value return, a shared queue Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-07 17:37 +0100

Page 4 of 4 — ← Prev page 1 2 3 [4]


#89471

FromMuttley@dastardlyhq.com
Date2023-03-06 09:18 +0000
Message-ID<tu4b4p$1l8m1$1@dont-email.me>
In reply to#89432
On Sat, 4 Mar 2023 18:41:19 +0100
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 04.03.2023 um 18:14 schrieb Muttley@dastardlyhq.com:
>
>> On Sat, 4 Mar 2023 18:06:47 +0100
>
>>> This also doesn't work because you don't test if there are items
>>> inside the queue.
>
>> Fine, do a check ....
>
>You said that you would give an example.
>But it doesn't work for a few reasons.

Feel free to list them.

>> Have you ever used condition variables?
>
>Check my code, it uses a CV.

So why don't you understand what wait() does?

>>> If you'd detach returning from main() and ending the program could occur
>>> earlier than any threads would complete. There's no guarantee that your
>>> runtime waits on detached threads.
>
>> There is that, but its hardly important. ...
>
>For your example code it would be.

No, it wouldn't. The whole point of detached threads is you don't care whether 
they terminate before the process terminates. If you did you wouldn't make them
detached in the first place! eg: a thread that blinks a cursor.


[toc] | [prev] | [next] | [standalone]


#89472

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-03-06 11:18 +0100
Message-ID<tu4ejd$1ljoi$1@dont-email.me>
In reply to#89471
Am 06.03.2023 um 10:18 schrieb Muttley@dastardlyhq.com:

> Feel free to list them.

I've shown them before, f.e. you're ignoring spurious wakeups.

> So why don't you understand what wait() does?

The wait doesn't make sense here, even with an example.

[toc] | [prev] | [next] | [standalone]


#89474

FromMuttley@dastardlyhq.com
Date2023-03-06 10:26 +0000
Message-ID<tu4f3t$1lljl$1@dont-email.me>
In reply to#89472
On Mon, 6 Mar 2023 11:18:43 +0100
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 06.03.2023 um 10:18 schrieb Muttley@dastardlyhq.com:
>
>> Feel free to list them.
>
>I've shown them before, f.e. you're ignoring spurious wakeups.

And I wrote how to solve that. Is that it?

>> So why don't you understand what wait() does?
>
>The wait doesn't make sense here, even with an example.

You don't understand what wait() does.

[toc] | [prev] | [next] | [standalone]


#89479

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-03-06 16:10 +0100
Message-ID<tu4vmg$1nbtv$1@dont-email.me>
In reply to#89474
Am 06.03.2023 um 11:26 schrieb Muttley@dastardlyhq.com:


> And I wrote how to solve that. Is that it?

Your code is lousy, even with this improvement,

> You don't understand what wait() does.

I know what wait does. And I also know that a producer-consumer
relationship doesn't need a wait, even with an example.

I've shown how to use sth. my queue-class form outside; thats
more convenient and less error-prone to to all the thins manually
each time. Using reusable components is mostly beneficial.

[toc] | [prev] | [next] | [standalone]


#89485

FromMuttley@dastardlyhq.com
Date2023-03-06 17:07 +0000
Message-ID<tu56ki$69u$1@dont-email.me>
In reply to#89479
On Mon, 6 Mar 2023 16:10:32 +0100
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 06.03.2023 um 11:26 schrieb Muttley@dastardlyhq.com:
>
>
>> And I wrote how to solve that. Is that it?
>
>Your code is lousy, even with this improvement,

Pot meet kettle.

>
>> You don't understand what wait() does.
>
>I know what wait does. And I also know that a producer-consumer
>relationship doesn't need a wait, even with an example.

FFS, the wait() was in the thread queue. 

>I've shown how to use sth. my queue-class form outside; thats
>more convenient and less error-prone to to all the thins manually
>each time. Using reusable components is mostly beneficial.

Like all your code, its far too complicated for the simple job it has to do.

[toc] | [prev] | [next] | [standalone]


#89501

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-03-07 06:44 +0100
Message-ID<tu6it7$9psi$1@dont-email.me>
In reply to#89485
Am 06.03.2023 um 18:07 schrieb Muttley@dastardlyhq.com:

> FFS, the wait() was in the thread queue.

It doesnt make sense at all.

> Like all your code, its far too complicated for the simple job it has to do.

This is a reusable component which is much easier to use
than what you have shown.

[toc] | [prev] | [next] | [standalone]


#89503

FromMuttley@dastardlyhq.com
Date2023-03-07 09:31 +0000
Message-ID<tu709i$bstl$1@dont-email.me>
In reply to#89501
On Tue, 7 Mar 2023 06:44:31 +0100
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 06.03.2023 um 18:07 schrieb Muttley@dastardlyhq.com:
>
>> FFS, the wait() was in the thread queue.
>
>It doesnt make sense at all.

It makes a lot more sense than any example code you'eve ever written. But
if you don't understand how condition variables control threads then fair
enough.

>> Like all your code, its far too complicated for the simple job it has to do.
>
>This is a reusable component which is much easier to use
>than what you have shown.

I can't imagine anyone using it in their code.

[toc] | [prev] | [next] | [standalone]


#89509

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-03-07 14:45 +0100
Message-ID<tu7f3d$e3tm$1@dont-email.me>
In reply to#89503
Am 07.03.2023 um 10:31 schrieb Muttley@dastardlyhq.com:

> On Tue, 7 Mar 2023 06:44:31 +0100

> Bonita Montero <Bonita.Montero@gmail.com> wrote:

>> It doesnt make sense at all.
> 
> It makes a lot more sense than any example code you'eve ever written. But
> if you don't understand how condition variables control threads then fair
> enough.

As far as you can see from my code I know how producer-consumer-patterns
are handled in C++. As far as I can see from your code you don't.

>> This is a reusable component which is much easier to use
>> than what you have shown.

> I can't imagine anyone using it in their code.

You can't say sat because you're too stupid to understand the code.

[toc] | [prev] | [next] | [standalone]


#89511

FromMuttley@dastardlyhq.com
Date2023-03-07 15:59 +0000
Message-ID<tu7n0a$fa66$1@dont-email.me>
In reply to#89509
On Tue, 7 Mar 2023 14:45:41 +0100
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 07.03.2023 um 10:31 schrieb Muttley@dastardlyhq.com:
>> I can't imagine anyone using it in their code.
>
>You can't say sat because you're too stupid to understand the code.

Producer-consumer is a simple solved problem. No one would use your dogs
dinner if you paid them.

[toc] | [prev] | [next] | [standalone]


#89512

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-03-07 17:37 +0100
Message-ID<tu7p5h$fkra$1@dont-email.me>
In reply to#89511
Am 07.03.2023 um 16:59 schrieb Muttley@dastardlyhq.com:

> Producer-consumer is a simple solved problem.
> No one would use your dogs dinner if you paid them.

The easiest way is to use pre-defined components for that. I've
shown such a component which is much easier to use than handling
this manually. You didn't even understood that this is a reusable
component.

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

Back to top | Article view | comp.lang.c++


csiph-web