Event hooks / task queue

Hi there.
I’m going to make a project processing a number of serial inputs, which should act similar to a multitask OS, having a set of objects designed to perform a short atomic tasks with pipelined stream of data.

Since I’m dealing with a queued data, it should be processed through this pipeline, and all “modules” (objects) must run their relevant processing methods exactly once per main cycle initiated by a serial interrupt or a clause.

The question is if there is a standard way in AVR-gcc (C++) to organize a queue of event listeners and run all this queue at once by raising an event.

Of course, I can put a long list with method calls for each instance in the main loop function but maybe there is a more beautiful method of doing that, or an existing class that can process events by, say, collecting pointers to functions, “subscribing” them to a named or numbered event?
Thanks.

What Arduino board is this planned for?

a7

I wish!

That said, I think I remember an Arduino publish-subscribe library. Alternately, you'll have to DIY: A C++ Implementation of Publisher-Subscriber

It's not hard to do a basic one: I've had to do it occasionally but clearly it's much better if you have a built in framework you can use. There's always switching to a Raspberrry Pi and using C# :slight_smile:

There's this: Pubnub - Arduino Reference but I don't know what PubNub is.

For Mega 2560. It has plenty of UARTs and enough RAM to place lots of FIFO buffers and object instances. Also, since it has lot of flash which is useful for storing static tables.
Also I have a whole box of these boards so I could program a squad of moonlanders with that.

Thanks for the link. Looks like a fairly simple implementation.
The reason why I prefer using C++ is simple: I can test my ideas on Arduino 2560 and then just develop my own cheap board using this MCU. The 32-bit units or Linux-based microcomputers are overkill for my tasks.
I got used to asm and C but I like the idea of polymorphism, which will be useful for the project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.