You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
In the code base I m working on, I found a custom implementation of the System.Reactive.Linq.Buffer operator.
Therefore my first reflex was to replace this homemade version by the existing Buffer.
If I grasp the intention of this alternate implementation, there was a special attention put to assure the buffered data was use a fixed size allocated buffer. At first, I couldn't believe this was that useful therefore I checked the implementation of Buffer in the repo.
It seems currently we allocate a List of element wo specifying the size of the list, then we add each by each element to the list and forward the list once list is full or and of stream.
I was wondering if performance is really a must - here in my case we visualize signal data in real time on screen - I was wondering if, as I know only one subscription will be consuming my stream, could I pass to Reactive the buffer I want to use to store my buffered data.
I realized that to keep the returned IList object, I may need to tweek a bit the underlined impl of it.
As I would like that interface to just being a view on the allocated buffer.
something that might like like this following snippet.
class ListView<T> : IList<T>
{
private readonly IList<T> _buffer;
private readonly int _count; // first empty index ready to be filled
public ListView(IList<T> data){..}
public Add(T element) => _buffer[_count++] = element;
public count => _count;
}
this is basically summarizing this idea, could you please share your comments/opinions on such approach?
PS: I indeed checked if this simple idea was already suggested, but wasn't able to point to a previous discussion or trace
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
In the code base I m working on, I found a custom implementation of the System.Reactive.Linq.Buffer operator.
Therefore my first reflex was to replace this homemade version by the existing Buffer.
If I grasp the intention of this alternate implementation, there was a special attention put to assure the buffered data was use a fixed size allocated buffer. At first, I couldn't believe this was that useful therefore I checked the implementation of Buffer in the repo.
It seems currently we allocate a List of element wo specifying the size of the list, then we add each by each element to the list and forward the list once list is full or and of stream.
I was wondering if performance is really a must - here in my case we visualize signal data in real time on screen - I was wondering if, as I know only one subscription will be consuming my stream, could I pass to Reactive the buffer I want to use to store my buffered data.
Something like
I realized that to keep the returned IList object, I may need to tweek a bit the underlined impl of it.
As I would like that interface to just being a view on the allocated buffer.
something that might like like this following snippet.
this is basically summarizing this idea, could you please share your comments/opinions on such approach?
PS: I indeed checked if this simple idea was already suggested, but wasn't able to point to a previous discussion or trace
Beta Was this translation helpful? Give feedback.
All reactions