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.
Diff: SharedObject.h
- Revision:
- 0:6c75b6083087
- Child:
- 1:fe38610c777b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SharedObject.h Fri Jul 19 03:28:14 2013 +0000
@@ -0,0 +1,42 @@
+#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.
+ */
+ inline void get (T& value_destination) const;
+
+ /** Sets the value of the shared resource with the specified new_value.
+ */
+ inline void set (const T& new_value);
+};
+
+
+#endif
\ No newline at end of file