Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
wifi-x-nucleo-idw01m1/BlockExecuter.h@0:8f8e8f3cbd1c, 2018-06-21 (annotated)
- Committer:
- mayur098
- Date:
- Thu Jun 21 17:50:21 2018 +0000
- Revision:
- 0:8f8e8f3cbd1c
first commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mayur098 | 0:8f8e8f3cbd1c | 1 | #ifndef BLOCK_EXEC_H |
mayur098 | 0:8f8e8f3cbd1c | 2 | #define BLOCK_EXEC_H |
mayur098 | 0:8f8e8f3cbd1c | 3 | |
mayur098 | 0:8f8e8f3cbd1c | 4 | #include "mbed.h" |
mayur098 | 0:8f8e8f3cbd1c | 5 | |
mayur098 | 0:8f8e8f3cbd1c | 6 | /* Helper class to execute something whenever entering/leaving a basic block */ |
mayur098 | 0:8f8e8f3cbd1c | 7 | class BlockExecuter { |
mayur098 | 0:8f8e8f3cbd1c | 8 | public: |
mayur098 | 0:8f8e8f3cbd1c | 9 | BlockExecuter(Callback<void()> exit_cb, Callback<void()> enter_cb = Callback<void()>()) : |
mayur098 | 0:8f8e8f3cbd1c | 10 | _exit_cb(exit_cb) { |
mayur098 | 0:8f8e8f3cbd1c | 11 | if((bool)enter_cb) enter_cb(); |
mayur098 | 0:8f8e8f3cbd1c | 12 | } |
mayur098 | 0:8f8e8f3cbd1c | 13 | |
mayur098 | 0:8f8e8f3cbd1c | 14 | ~BlockExecuter(void) { |
mayur098 | 0:8f8e8f3cbd1c | 15 | _exit_cb(); |
mayur098 | 0:8f8e8f3cbd1c | 16 | } |
mayur098 | 0:8f8e8f3cbd1c | 17 | |
mayur098 | 0:8f8e8f3cbd1c | 18 | private: |
mayur098 | 0:8f8e8f3cbd1c | 19 | Callback<void()> _exit_cb; |
mayur098 | 0:8f8e8f3cbd1c | 20 | }; |
mayur098 | 0:8f8e8f3cbd1c | 21 | |
mayur098 | 0:8f8e8f3cbd1c | 22 | #endif //BLOCK_EXEC_H |