* src/toolbox/list.hpp (List): Added new list class without a mutex.
[cacao.git] / src / toolbox / list.hpp
index 0ca05c82e7b53f90496b94440eb23681afefff5c..1509f1ba00e59be41da99eac33bef34710c0a2c1 100644 (file)
 #include <stdint.h>
 
 #ifdef __cplusplus
-#include <list>
-#endif
-
-#include "threads/mutex.hpp"
 
-
-#ifdef __cplusplus
+#include <list>
 
 /**
- * List implementation with a Mutex.
+ * List implementation.
  */
 template<class T> class List : protected std::list<T> {
-private:
-       Mutex _mutex;
-
 public:
-       virtual ~List() {}
-
-       void lock  () { _mutex.lock(); }
-       void unlock() { _mutex.unlock(); }
-
        // make iterator of std::list visible
        using std::list<T>::iterator;
        using std::list<T>::reverse_iterator;
@@ -72,6 +59,25 @@ public:
 };
 
 
+// Required by LockedList.
+#include "threads/mutex.hpp"
+
+
+/**
+ * List implementation with a Mutex.
+ */
+template<class T> class LockedList : public List<T> {
+private:
+       Mutex _mutex;
+
+public:
+       virtual ~LockedList() {}
+
+       void lock  () { _mutex.lock(); }
+       void unlock() { _mutex.unlock(); }
+};
+
+
 // Required by DumpList.
 #include "mm/dumpmemory.hpp"
 
@@ -111,6 +117,7 @@ public:
 #else
 
 typedef struct List List;
+typedef struct LockedList LockedList;
 typedef struct DumpList DumpList;
 
 #endif