Boost logo

Boost :

Subject: Re: [boost] A class for embedded friendly callbacks.
From: Mikael Rosbacke (mikael_at_[hidden])
Date: 2019-01-07 11:15:17

On 2019-01-07 11:27, Vinícius dos Santos Oliveira wrote:
> Em sáb, 5 de jan de 2019 às 22:13, Mikael Rosbacke via Boost
> <boost_at_[hidden] <mailto:boost_at_[hidden]>> escreveu:
> I'm Mikael Rosbacke and new to this list. The last couple of
> months I've
> been writing on a class for storing callbacks to different forms of
> callables (member functions, functors, free functions). The main
> focus
> has been to make it suitable for embedded work with small
> footprint and
> dependable exception and heap behavior. The code can be found on
> github:
> Do you think your use case could be served by
> dyno<>?

It is an interesting suggestion. Louis Dionne have done a deep dive into
polymorphism in this case. It seems poly aims to improve on traditional
runtime polymorphism with dynamic dispatching on member functions, but
less use of explicit inheritance from interfaces. It seems related to
Sean Parents work to avoid explicit inheritance.

It does seem to be a different approach in that the delegate expands on
the idea of a pointer, being a view to something else, while the 'poly'
starts from the object oriented approach and want to improve on dynamic

In my case, the C++17 requirement and different meta programming
dependencies are a bit daunting in an embedded setting where the
toolchains often lags the standard substantially. In this case, the
C++11 compatibility does matter for usability. At this point maybe C++14
is viable for broad use.

One use case I see for the delegate is as an extended interrupt vector
table. In micro-controllers you can set up interrupt handler to call a
free function when something hardware related happens. You could hard
code these to call a delegate in an array. Then drivers can register
their functions to be called and got the freedom to chose member
functions, free functions etc. With the delegate you get that extra data
pointer storage needed to call a function on an object.

--- Mikael R

> --
> Vinícius dos Santos Oliveira

Boost list run by bdawes at, gregod at, cpdaniel at, john at