Interrupts are like threads, except worse because you have also reentrancy issues (e.g., can IRQ A happen while the handler for IRQ A is still running, possibly outside of IRQ context). Volatile is not sufficient for several reasons, not
the least because insertion/removal into a linked list is not an atomic operation. As I see it you have two choices:
You should read about how operating systems (Windows, Linux) tackle these issues.
From: Boost-users <boost-users-bounces@lists.boost.org>
On Behalf Of nat ersoz via Boost-users
Sent: Sunday, November 25, 2018 18:38
To: boost-users@lists.boost.org
Cc: nat ersoz <natersoz@gmail.com>
Subject: [Boost-users] Boost intrusive list volatile hook
I intend to use the boost intrusive list to implement an observer pattern.
I have a minimal code sample here:
https://github.com/natersoz/patterns/blob/master/observer/intrusive_list_member/test_observer_minimal.cc
My list hook member declaration:
using list_hook_type = boost::intrusive::list_member_hook<
boost::intrusive::link_mode<boost::intrusive::auto_unlink>
>;
list_hook_type hook;
My list declaration:
using list_type =
boost::intrusive::list<
Observer<NotificationType>,
boost::intrusive::constant_time_size<false>,
boost::intrusive::member_hook<
Observer<NotificationType>,
typename Observer<NotificationType>::list_hook_type,
&Observer<NotificationType>::hook>
>;
If I a the volatile keyword to the list hood type, I cannot figure out how to get the list_type declaration to fit into the list template list.
Is it possible?
Thank you.
--
Nat Ersoz
425-417-5182 (cell)