Simple program for introduction of mirror actuator.
Embed:
(wiki syntax)
Show/hide line numbers
ThreadFlag.cpp
00001 /* 00002 * ThreadFlag.cpp 00003 * Copyright (c) 2019, ZHAW 00004 * All rights reserved. 00005 * 00006 * Created on: 29.11.2019 00007 * Author: Marcel Honegger 00008 */ 00009 00010 #include "ThreadFlag.h" 00011 00012 using namespace std; 00013 00014 uint32_t ThreadFlag::threadFlags = 0; 00015 00016 /** 00017 * Creates a signal object and assignes a unique flag. 00018 */ 00019 ThreadFlag::ThreadFlag() { 00020 00021 mutex.lock(); 00022 00023 uint32_t n = 0; 00024 while ((((1 << n) & threadFlags) > 0) && (n < 30)) n++; 00025 threadFlag = (1 << n); 00026 00027 mutex.unlock(); 00028 } 00029 00030 /** 00031 * Deletes the signal object and releases the assigned flag. 00032 */ 00033 ThreadFlag::~ThreadFlag() { 00034 00035 mutex.lock(); 00036 00037 threadFlags &= ~threadFlag; 00038 00039 mutex.unlock(); 00040 } 00041 00042 /** 00043 * Gets the assigned thread flag. 00044 */ 00045 uint32_t ThreadFlag::read() { 00046 00047 return threadFlag; 00048 } 00049 00050 /** 00051 * The empty operator is a shorthand notation of the <code>read()</code> method. 00052 */ 00053 ThreadFlag::operator uint32_t() { 00054 00055 return read(); 00056 } 00057
Generated on Sun Jul 17 2022 14:09:45 by
1.7.2