Mbed os and lamba functions

Given that we are all now encouraged to do asynchronous programming I found using C++ lambda functions quite useful to avoid polluting the file with static callbacks everywhere eg…

// Register function to be called when button is released
button.rise( {
// Calling BLE api in interrupt context may cause race conditions
// Using minar to schedule calls to BLE api for safety
Scheduler::postCallback( buttonPressCallback );
} );

any thoughts opinions… ?

1 Like

Yep, I’m a big fan of lambdas too. C++11 FTW.