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
ThreadFlag.cpp
00001 /* 00002 * ThreadFlag.cpp 00003 * Copyright (c) 2020, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #include "ThreadFlag.h" 00008 00009 using namespace std; 00010 00011 unsigned int ThreadFlag::threadFlags = 0; 00012 00013 /** 00014 * Creates a signal object and assignes a unique flag. 00015 */ 00016 ThreadFlag::ThreadFlag() 00017 { 00018 mutex.lock(); 00019 00020 unsigned int n = 0; 00021 while ((((1 << n) & threadFlags) > 0) && (n < 30)) n++; 00022 threadFlag = (1 << n); 00023 00024 mutex.unlock(); 00025 } 00026 00027 /** 00028 * Deletes the signal object and releases the assigned flag. 00029 */ 00030 ThreadFlag::~ThreadFlag() 00031 { 00032 mutex.lock(); 00033 00034 threadFlags &= ~threadFlag; 00035 00036 mutex.unlock(); 00037 } 00038 00039 /** 00040 * Gets the assigned thread flag. 00041 */ 00042 unsigned int ThreadFlag::read() 00043 { 00044 return threadFlag; 00045 } 00046 00047 /** 00048 * The empty operator is a shorthand notation of the <code>read()</code> method. 00049 */ 00050 ThreadFlag::operator unsigned int() 00051 { 00052 return read(); 00053 } 00054
Generated on Tue Jul 12 2022 21:20:55 by
1.7.2
