by injinj · 5y ago · 0 comments
volatile T member;
T access( void ) { return member; }
Use volatile on the functions instead: T member;
T access( void ) volatile { return member; }
This has causes all access to this-> within the function to be volatile, including read_position, write_position, overrun_flag and data[].When inlining these functions within other parts of the code, the compiler can hoist reads into registers from the non-volatile members unless you add the compiler barrier that @ghhhhhk8899jj mentioned.
No comments yet.