Over a million developers have joined DZone.

RingBuffer Component with Put/Get/Clear Events

· IoT Zone

Sometimes I have a good idea how to extend one of my Processor Expert components with an extra feature, but then I step back because why implementing more than I need at the moment? Until another user of the component simply asks for the same thing, and here we go: if one or more can take advantage of a feature, that’s definitely a strong argument to add it :-). This happened with the RingBuffer Processor Expert component I’m using in many projects. And a reader of this blog asked to add some extra event methods: when an item is added or removed to the buffer.

RingBuffer used in USB Component with Extra Events

RingBuffer used in USB Component with Extra Events

Beside of the OnItemPut() and OnItemGet() events, I added an extra OnClear() event which gets called when the ring buffer Clear() method gets called. The events are disabled  by default not to add any overhead, and they can be enabled individually.

Using the CDE (Component Development Environment) of Processor Expert makes it very easy to such additional events: define the interface for the event, and then add the event code to the driver. Below shows it for the Put() method:

To check the details of the change, see the commit on GitHub.

So with using the new RingBuffer events in my USB stack, I can get application notifications for every byte received or sent, which is very useful.

The updated component will be available with the next *.PEupd release.

Happy Eventing :-)

Topics:

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}