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.
Fork of LcdWindow by
semaphore.h@13:99b500b05716, 2016-01-13 (annotated)
- Committer:
- charly
- Date:
- Wed Jan 13 19:38:54 2016 +0000
- Revision:
- 13:99b500b05716
- Parent:
- 9:2fe93daa2106
added enableDisplay and disableDisplay for Terminal to stop the output to LCD.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hlipka | 3:e5d5e2fe4bf6 | 1 | /** |
| hlipka | 3:e5d5e2fe4bf6 | 2 | * code from Igor Skochinsky |
| hlipka | 3:e5d5e2fe4bf6 | 3 | * taken from http://mbed.org/forum/mbed/post/799/ |
| hlipka | 3:e5d5e2fe4bf6 | 4 | */ |
| hlipka | 3:e5d5e2fe4bf6 | 5 | |
| hlipka | 3:e5d5e2fe4bf6 | 6 | #ifndef SEMAPHORE_H_ |
| hlipka | 3:e5d5e2fe4bf6 | 7 | #define SEMAPHORE_H_ |
| hlipka | 3:e5d5e2fe4bf6 | 8 | |
| hlipka | 3:e5d5e2fe4bf6 | 9 | class Semaphore |
| hlipka | 3:e5d5e2fe4bf6 | 10 | { |
| hlipka | 3:e5d5e2fe4bf6 | 11 | public: |
| hlipka | 3:e5d5e2fe4bf6 | 12 | // constructor |
| hlipka | 3:e5d5e2fe4bf6 | 13 | Semaphore(); |
| hlipka | 3:e5d5e2fe4bf6 | 14 | |
| hlipka | 3:e5d5e2fe4bf6 | 15 | // try to take the semaphore and return success |
| hlipka | 3:e5d5e2fe4bf6 | 16 | // by default block until succeeded |
| hlipka | 3:e5d5e2fe4bf6 | 17 | bool take(bool block = true); |
| hlipka | 3:e5d5e2fe4bf6 | 18 | // release the semaphore |
| hlipka | 3:e5d5e2fe4bf6 | 19 | void release(); |
| hlipka | 3:e5d5e2fe4bf6 | 20 | |
| hlipka | 9:2fe93daa2106 | 21 | static void setAbort(bool abort){_abort=abort;}; |
| hlipka | 9:2fe93daa2106 | 22 | |
| hlipka | 3:e5d5e2fe4bf6 | 23 | private: |
| hlipka | 3:e5d5e2fe4bf6 | 24 | enum { SemFree, SemTaken }; |
| hlipka | 3:e5d5e2fe4bf6 | 25 | // semaphore value |
| hlipka | 3:e5d5e2fe4bf6 | 26 | int s; |
| hlipka | 9:2fe93daa2106 | 27 | static bool _abort; |
| hlipka | 3:e5d5e2fe4bf6 | 28 | |
| hlipka | 3:e5d5e2fe4bf6 | 29 | }; |
| hlipka | 3:e5d5e2fe4bf6 | 30 | |
| hlipka | 3:e5d5e2fe4bf6 | 31 | #endif |
