test

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

BlockExecuter.h

Committer:
karen801
Date:
2018-05-23
Revision:
0:79ce2b184a43

File content as of revision 0:79ce2b184a43:

#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