test

Dependents:   mbed-os-example-blinky-1stDevDemo

Revision:
0:79ce2b184a43
diff -r 000000000000 -r 79ce2b184a43 BlockExecuter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BlockExecuter.h	Wed May 23 14:37:10 2018 +0000
@@ -0,0 +1,22 @@
+#ifndef BLOCK_EXEC_H
+#define BLOCK_EXEC_H
+
+#include "mbed.h"
+
+/* Helper class to execute something whenever entering/leaving a basic block */
+class BlockExecuter {
+public:
+    BlockExecuter(Callback<void()> exit_cb, Callback<void()> enter_cb = Callback<void()>()) :
+        _exit_cb(exit_cb) {
+        if((bool)enter_cb) enter_cb();
+    }
+
+    ~BlockExecuter(void) {
+        _exit_cb();
+    }
+
+private:
+    Callback<void()> _exit_cb;
+};
+
+#endif  //BLOCK_EXEC_H