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.
SharedObject.h
- Committer:
- MatteoT
- Date:
- 2013-07-19
- Revision:
- 1:fe38610c777b
- Parent:
- 0:6c75b6083087
- Child:
- 2:16cab88c1203
File content as of revision 1:fe38610c777b:
#ifndef _SHAREDOBJECT_H_
#define _SHAREDOBJECT_H_
#include "mbed.h"
#include "rtos.h"
/** Template class used to protect a shared resource with a Mutex.
*/
template <class T>
class SharedObject
{
/** get/set controll mutex
*/
Mutex _readwrite_mutex;
/** value of the object
*/
T _value;
public:
/** Resource constructor.
* @param value sets the initial value of the resource.
*/
SharedObject (const T& value);
/** Resource constructor without initial value.
*/
SharedObject ();
/** Sets the specified value_destination with the value of the shared resource.
*/
void get (T& value_destination) const;
/** Sets the value of the shared resource with the specified new_value.
*/
void set (const T& new_value);
};
#endif