Comments (10)
Yes, it is possible. It is indeed m-buffer (BUFFER_DEF with BUFFER_UNSAFE|BUFFER_QUEUE)
Why do you think it is not suitable?
from mlib.
I would imagine that a ring fixed-size buffer is something that loops its new last element all over again. Your implementation just rewrites the count - 1 element when the buffer is full.
from mlib.
I am not sure to understand what you mean.
BUFFER_DEF with a BUFFER_QUEUE implements a ring buffer as explained here: https://en.wikipedia.org/wiki/Circular_buffer
from mlib.
Does start and end pointers actually change in your implementation?
from mlib.
Yes
from mlib.
What happens when you push an element to a full queue?
I want a thread-unsafe ring-buffer and using BUFFER_PUSH_OVERWRITE also. The pushing seems to always overwrite the last element (count - 1)
from mlib.
I seem to miss the point, maybe. is BUFFER_PUSH_OVERWRITE mandatory for thread-unsafe buffers?
from mlib.
What happens when you push an element to a full queue?
It depends on the configuration of the queue. It may:
- block until the queue is not full (if BUFFER_THREAD_SAFE)
- overwrite the youngest element if BUFFER_PUSH_OVERWRITE
- return a failure otherwise.
I want a thread-unsafe ring-buffer and using BUFFER_PUSH_OVERWRITE also. The pushing seems to always overwrite the last element (count - 1)
This is what BUFFER_PUSH_OVERWRITE does (overwrite the youngest element in case of buffer full) to avoid blocking.
is BUFFER_PUSH_OVERWRITE mandatory for thread-unsafe buffers?
No
from mlib.
Ok, I now seem to get it. Thank you.
But it still looks kinda un-optimal that atomic is used in a thread-unsafe version.
what do you think?
from mlib.
It is true! Thanks. I have opened an issue on it: #90
from mlib.
Related Issues (20)
- Compiler errors HOT 3
- README example not work HOT 3
- Add EMPLACE_TYPE support for B+TREE, DICT, RB-TREE, BUFFER, CONCURRENT HOT 3
- bitset: function for getting minimum index with bit set HOT 3
- Memory leak HOT 5
- How to define REALLOC in OPLIST? HOT 1
- Bug in list? HOT 1
- Allocator customization HOT 2
- How to define a set of pointer? HOT 1
- Github actions failure HOT 1
- Possible assertion error HOT 6
- Wrong implementation for set_cstr for bounded strings HOT 16
- M_EMPTY_P(max) doesn't work HOT 4
- BPTREEI_OPLIST2_P4 missing push definition?
- BUFFER_DEF / BUFFER_THREAD_UNSAFE: performance issue HOT 1
- RB-tree _it_from on root node HOT 1
- Memory issue with _pop_at function while using 2d arrays HOT 1
- string_t: extremely confusing methods names: string_clean and string_clear HOT 5
- Change _str suffix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlib.