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.
Dependencies: LSM9DS1 RangeFinder FastPWM
Dependents: PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board ... more
Diff: ThreadFlag.cpp
- Revision:
- 4:9c003c402033
- Parent:
- 0:86129f1b4a93
--- a/ThreadFlag.cpp Thu Apr 01 14:31:43 2021 +0000
+++ b/ThreadFlag.cpp Tue Apr 06 11:21:54 2021 +0000
@@ -13,42 +13,42 @@
/**
* Creates a signal object and assignes a unique flag.
*/
-ThreadFlag::ThreadFlag() {
-
+ThreadFlag::ThreadFlag()
+{
mutex.lock();
-
+
unsigned int n = 0;
while ((((1 << n) & threadFlags) > 0) && (n < 30)) n++;
threadFlag = (1 << n);
-
+
mutex.unlock();
}
/**
* Deletes the signal object and releases the assigned flag.
*/
-ThreadFlag::~ThreadFlag() {
-
+ThreadFlag::~ThreadFlag()
+{
mutex.lock();
-
+
threadFlags &= ~threadFlag;
-
+
mutex.unlock();
}
/**
* Gets the assigned thread flag.
*/
-unsigned int ThreadFlag::read() {
-
+unsigned int ThreadFlag::read()
+{
return threadFlag;
}
/**
* The empty operator is a shorthand notation of the <code>read()</code> method.
*/
-ThreadFlag::operator unsigned int() {
-
+ThreadFlag::operator unsigned int()
+{
return read();
}
