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.
Dependents: SmartLight HelloThreadsYo
mutexlocker.h
00001 /* (C) 2014 Richard Thompson (Tomo2k) 00002 This software is Apache 2.0 licenced for this to be reused. 00003 00004 That said, it's trivial and rather obvious! 00005 */ 00006 #pragma once 00007 00008 #include "rtos.h" 00009 00010 00011 //! Lock/Unlock Mutex using variable scope. 00012 //! Ensures always unlocked regardless of method exit 00013 class MutexLocker 00014 { 00015 public: 00016 //! Lock the mutex 00017 MutexLocker(Mutex &mutex) : 00018 m_mutex(mutex) { 00019 m_mutex.lock(); 00020 } 00021 //! Unlocks on destruction 00022 ~MutexLocker() { 00023 m_mutex.unlock(); 00024 } 00025 private: 00026 Mutex &m_mutex; 00027 // Disable copy 00028 MutexLocker & operator=(const MutexLocker&); 00029 MutexLocker(const MutexLocker &); 00030 };
Generated on Wed Jul 20 2022 20:53:50 by
1.7.2