Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BlockExecuter.h Source File

BlockExecuter.h

00001 #ifndef BLOCK_EXEC_H
00002 #define BLOCK_EXEC_H
00003 
00004 #include "mbed.h"
00005 
00006 /* Helper class to execute something whenever entering/leaving a basic block */
00007 class BlockExecuter {
00008 public:
00009     BlockExecuter(Callback<void()> exit_cb, Callback<void()> enter_cb = Callback<void()>()) :
00010         _exit_cb(exit_cb) {
00011         if((bool)enter_cb) enter_cb();
00012     }
00013 
00014     ~BlockExecuter(void) {
00015         _exit_cb();
00016     }
00017 
00018 private:
00019     Callback<void()> _exit_cb;
00020 };
00021 
00022 #endif  //BLOCK_EXEC_H