Just a ring-buffer with functional access:
Am 20.09.2024 um 16:10 schrieb [email protected]:
A ring buffer can be written about 10 lines of code ...
A deque is also much more complex than you think it is necessary.
Am 20.09.2024 um 17:08 schrieb [email protected]:
A deque is not needed for a ring buffer.
Both usually serve the same purpose. A deque has iterators and therefore
Using one demonstrates you don't actually know what a ring buffer is.
You are overburdened with my code and you didn't read it.
I implemented a very convenient to use ring-buffer.
Am 20.09.2024 um 17:57 schrieb [email protected]:
No, they don't. A deque can have an unbounded (except by memory)
number of items whereas a ring buffer is by design a fixed size.
A ring-buffer can be growing, my implementation also does grow.
The Boost ringbuffer also can grow.
People like yourself are responsible for the absurd amount of bloat
in modern code and ridiculously powerful CPUs being required just
to run office style applications and web pages.
The "bloat" results in very few code of who uses this "bloat".
You're simply overburdened. Have a look at the standard library
code, it's much more complex for things which might look trivial
to you.
On Fri, 20 Sep 2024 18:03:14 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 20.09.2024 um 17:57 schrieb [email protected]:
No, they don't. A deque can have an unbounded (except by memory)
number of items whereas a ring buffer is by design a fixed size.
A ring-buffer can be growing, my implementation also does grow.
A ringbuffer that can grow is not a ring buffer, its a deque as you figured out.
The Boost ringbuffer also can grow.
Boost has a lot to answer for in many areas.
People like yourself are responsible for the absurd amount of bloat
in modern code and ridiculously powerful CPUs being required just
to run office style applications and web pages.
The "bloat" results in very few code of who uses this "bloat".
You're simply overburdened. Have a look at the standard library
Am I? I think it might be you who can't think clearly enough to write a
clean simple algorithm for a simple data structure.
code, it's much more complex for things which might look trivial
to you.
Ring buffers are trivial.
Am 21.09.2024 um 14:18 schrieb Chris Ahlstrom:
I wrote a ringbuffer template class that is "similar" in size and scope.
Probably could refine it further.
He thinks he could write that in 10 lines without noticing the requirements.
[email protected] wrote this copyrighted missive and expects royalties:
On Fri, 20 Sep 2024 18:03:14 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 20.09.2024 um 17:57 schrieb [email protected]:
No, they don't. A deque can have an unbounded (except by memory)
number of items whereas a ring buffer is by design a fixed size.
A ring-buffer can be growing, my implementation also does grow.
A ringbuffer that can grow is not a ring buffer, its a deque as you figured >> out.
The Boost ringbuffer also can grow.
Boost has a lot to answer for in many areas.
People like yourself are responsible for the absurd amount of bloat
in modern code and ridiculously powerful CPUs being required just
to run office style applications and web pages.
The "bloat" results in very few code of who uses this "bloat".
You're simply overburdened. Have a look at the standard library
Am I? I think it might be you who can't think clearly enough to write a
clean simple algorithm for a simple data structure.
code, it's much more complex for things which might look trivial
to you.
Ring buffers are trivial.
Depends what you want. The ringbuffer.c module in the jack2 project is 420 lines including comments and #ifdefs. It also provides optional locking, and some convenience functions.
I wrote a ringbuffer template class that is "similar" in size and scope. Probably could refine it further.
Am 21.09.2024 um 19:03 schrieb jseigh:
I have a ringbuffer implementation that is lock-free, internally ABA
proof, and is about 400 loc I think. It supports mpmc, spsc, spmc,
and mpsc.
Lock-free ring-buffers are technically nice but suck since they have
to be polled. Better a mutex'd solution with a mutex that has a limited spin-count and a futex for the slow path.
On 9/21/2024 10:03 AM, jseigh wrote:
I have a ringbuffer implementation that is lock-free, internally ABA
proof, and is about 400 loc I think. It supports mpmc, spsc, spmc,
and mpsc.
Nice! Well, supporting all of those modes all in one is interesting to
me Joe. Usually, to gain performance on the various queue types mpmc,
spsc, ect... They each have their own special algorithms. An algorithm
for a spsc is going to be different that a mpmc? Of course mpmc handles
all of those conditions, however, the per impl aspect is important?
Am 21.09.2024 um 17:59 schrieb [email protected]:
I implented the sound output buffer for a virtual synth as a ring buffer.
That's a ring for _trivial_ C++ types, that's much easier. I can handle
complex C++ types with a vector<>-like emplace( )and I move them when
the ring is resized; that's much more effort.
And you need a dozen postings to understand what the static and variable >initialization parameters for a semaphore are good for.
Am 22.09.2024 um 09:58 schrieb [email protected]:
For complex types any sane person would just use an STL container as the
basis of a ring buffer instead of reinventing the wheel like you've done.
And the STL-container is a magnitude more complex. I developed
this little alternative because I needed a qeue for MSVC which
is as efficient as libstdc++'s or libc++'s deque.
<snip>
And you required a number of posts using loads of gibberish to attempt to explain yet you still failed. Meanwhile someone else managed it in 2 lines.
Am 21.09.2024 um 21:29 schrieb jseigh:
Lock-free is desirable for certain situations. Also there is a certain
presumption that if you are using lock-free mutable data structures you
sort of know what you are doing. Not rocket science level stuff.
Closer to "don't use uint8_t if the values might exceed 256" or "don't
do unbounded recursion" or "don't use evil regex's".
Show ma en open source project that uses lock-free queues without a
slow path.
Am 22.09.2024 um 11:01 schrieb [email protected]:
So what? The containers are already written for you and many clever eyes and >> minds have made sure they're as efficient as possible.
You're not just trying to explain away complexity with me because
it's too much for you.
So why didn't you just use std::deque then with a couple of wrapper >functions.
Because MSVC's std::deque and Boost's boost::container::deque is
multiple times slower. I needed a fast solution for all platforms.
<snip>
And you required a number of posts using loads of gibberish to attempt to
explain yet you still failed. Meanwhile someone else managed it in 2 lines.
Ahhh, the famous "2 lines of code" claim.
Am 22.09.2024 um 12:49 schrieb Chris Ahlstrom:
[email protected] wrote this copyrighted missive and expects royalties:
<snip>Ahhh, the famous "2 lines of code" claim.
And you required a number of posts using loads of gibberish to attempt to >>> explain yet you still failed. Meanwhile someone else managed it in 2 lines. >>
Muttley denies every language feature he doesn't understand in 10s.
Am 22.09.2024 um 17:16 schrieb [email protected]:
On Sun, 22 Sep 2024 06:49:13 -0400
Chris Ahlstrom <[email protected]> boringly babbled:
[email protected] wrote this copyrighted missive and expects >royalties:
<snip>
And you required a number of posts using loads of gibberish to attempt to >>>> explain yet you still failed. Meanwhile someone else managed it in 2 lines.
Ahhh, the famous "2 lines of code" claim.
Who said anything about code?
You said you could replace my code with 10 lines of code - without
noticing what it does.
Am 23.09.2024 um 09:35 schrieb [email protected]:
On Sun, 22 Sep 2024 17:31:34 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 22.09.2024 um 17:16 schrieb [email protected]:
On Sun, 22 Sep 2024 06:49:13 -0400royalties:
Chris Ahlstrom <[email protected]> boringly babbled:
[email protected] wrote this copyrighted missive and expects
<snip>
And you required a number of posts using loads of gibberish to attempt to
explain yet you still failed. Meanwhile someone else managed it in 2 >lines.
Ahhh, the famous "2 lines of code" claim.
Who said anything about code?
You said you could replace my code with 10 lines of code - without
noticing what it does.
I was refering to how someone explained the reason for the template param of >> semaphores in 2 lines whereas you and others spent paragraphs trying and
failing.
You needed several descriptions which were all correct.
On Mon, 23 Sep 2024 09:36:32 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 23.09.2024 um 09:35 schrieb [email protected]:
On Sun, 22 Sep 2024 17:31:34 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 22.09.2024 um 17:16 schrieb [email protected]:
On Sun, 22 Sep 2024 06:49:13 -0400royalties:
Chris Ahlstrom <[email protected]> boringly babbled:
[email protected] wrote this copyrighted missive and
expects
<snip>
And you required a number of posts using loads of gibberish to
attempt to
lines.explain yet you still failed. Meanwhile someone else managed
it in 2
Ahhh, the famous "2 lines of code" claim.
Who said anything about code?
You said you could replace my code with 10 lines of code - without
noticing what it does.
I was refering to how someone explained the reason for the
template param of semaphores in 2 lines whereas you and others
spent paragraphs trying and failing.
You needed several descriptions which were all correct.
Several descriptions which all parotted the cppreference page which
doesn't explain it properly otherwise I wouldn't have asked.
On Mon, 23 Sep 2024 09:31:09 -0000 (UTC)
[email protected] wrote:
On Mon, 23 Sep 2024 09:36:32 +0200
Bonita Montero <[email protected]> boringly babbled:
Am 23.09.2024 um 09:35 schrieb [email protected]:
On Sun, 22 Sep 2024 17:31:34 +0200lines.
Bonita Montero <[email protected]> boringly babbled:
Am 22.09.2024 um 17:16 schrieb [email protected]:
On Sun, 22 Sep 2024 06:49:13 -0400royalties:
Chris Ahlstrom <[email protected]> boringly babbled:
[email protected] wrote this copyrighted missive and
expects
<snip>
And you required a number of posts using loads of gibberish to >>>>>>>> attempt to
explain yet you still failed. Meanwhile someone else managed
it in 2
Ahhh, the famous "2 lines of code" claim.
Who said anything about code?
You said you could replace my code with 10 lines of code - without
noticing what it does.
I was refering to how someone explained the reason for the
template param of semaphores in 2 lines whereas you and others
spent paragraphs trying and failing.
You needed several descriptions which were all correct.
Several descriptions which all parotted the cppreference page which
doesn't explain it properly otherwise I wouldn't have asked.
I wonder which of explanations that you had gotten do you consider satisfactory?
If you are thinking about explanation given by David Brown then I am
quite sure that despite sounding convincing his explanation is wrong.
In a typical implementation counting semaphores *do not* maintain list
of IDs of waiting threads within std::counting_semaphore object.
The article on cppreference.com that does not try to explain why LeastMaxValue is a template parameter seems to me as the most adequate, because logical explanation for that choice does not exist.
It would have been much more logical if the type of the counter rather
than its max value had been chosen as a template parameter. Of course
with requirement that the type has to be signed integer.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 157:08:40 |
| Calls: | 12,093 |
| Calls today: | 1 |
| Files: | 15,000 |
| Messages: | 6,517,750 |