It would be useful to add the option to allow the linked ring buffer to overflow when it is filled, discarding the oldest data in favor of the new data. This could be useful in certain scenarios where it is necessary to store more data in the buffer than it can hold.
Discussion
There are a few considerations to keep in mind when implementing this feature:
Should this be a general setting for the buffer, or a special method?
How does the user know that the buffer is being overwritten?
Should the buffer be overwritten only for the specified owner?
One approach could be to modify the lr_put() function to check if the buffer is full before adding a new element, and provide a flag or configuration option to allow users to specify whether they want to enable overflow behavior or not. This could be a general setting for the buffer that applies to all owners.
To let the user know that the buffer is being overwritten, the lr_put() function could return a special return code or status message indicating that the element was added to the buffer, but buffer is full and overflow behavior is enabled.
Alternatively, the buffer could be overwritten only for the specified owner, using the same mechanism.
It would be useful to add the option to allow the linked ring buffer to overflow when it is filled, discarding the oldest data in favor of the new data. This could be useful in certain scenarios where it is necessary to store more data in the buffer than it can hold.
Discussion
There are a few considerations to keep in mind when implementing this feature:
One approach could be to modify the
lr_put()
function to check if the buffer is full before adding a new element, and provide a flag or configuration option to allow users to specify whether they want to enable overflow behavior or not. This could be a general setting for the buffer that applies to all owners.To let the user know that the buffer is being overwritten, the
lr_put()
function could return a special return code or status message indicating that the element was added to the buffer, but buffer is full and overflow behavior is enabled.Alternatively, the buffer could be overwritten only for the specified owner, using the same mechanism.