(LockedList): Renamed list class with mutex to make mutex obvious.
* src/threads/threadlist.hpp (ThreadList): Use above class.
* src/threads/threadlist.cpp: Likewise.
* src/vm/jit/code.hpp (codeinfo): Patcher list uses above class.
* src/vm/jit/patcher-common.cpp (patcher_list_create): Likewise.
Mutex ThreadList::_mutex; // a mutex for all thread lists
-list<threadobject*> ThreadList::_active_thread_list; // list of active threads
-list<threadobject*> ThreadList::_free_thread_list; // list of free threads
-list<int32_t> ThreadList::_free_index_list; // list of free thread indexes
+List<threadobject*> ThreadList::_active_thread_list; // list of active threads
+List<threadobject*> ThreadList::_free_thread_list; // list of free threads
+List<int32_t> ThreadList::_free_index_list; // list of free thread indexes
int32_t ThreadList::_number_of_non_daemon_threads;
*
* @param list list class to be filled
*/
-void ThreadList::get_active_threads(list<threadobject*> &list)
+void ThreadList::get_active_threads(List<threadobject*> &list)
{
// Lock the thread lists.
lock();
#ifdef __cplusplus
-using std::list;
-
class ThreadList {
private:
static Mutex _mutex; // a mutex for all thread lists
- static list<threadobject*> _active_thread_list; // list of active threads
- static list<threadobject*> _free_thread_list; // list of free threads
- static list<int32_t> _free_index_list; // list of free thread indexes
+ static List<threadobject*> _active_thread_list; // list of active threads
+ static List<threadobject*> _free_thread_list; // list of free threads
+ static List<int32_t> _free_index_list; // list of free thread indexes
static int32_t _number_of_non_daemon_threads;
static void add_to_active_thread_list(threadobject* t);
static void dump_threads();
- static void get_active_threads(list<threadobject*> &list);
+ static void get_active_threads(List<threadobject*> &list);
static threadobject* get_main_thread();
static threadobject* get_free_thread();
static int32_t get_free_thread_index();
#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;
};
+// 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"
#else
typedef struct List List;
+typedef struct LockedList LockedList;
typedef struct DumpList DumpList;
#endif
/* patcher list */
#ifdef __cplusplus
- List<patchref_t>* patchers;
+ LockedList<patchref_t>* patchers;
#else
- List* patchers;
+ LockedList* patchers;
#endif
/* replacement */
void patcher_list_create(codeinfo *code)
{
- code->patchers = new List<patchref_t>();
+ code->patchers = new LockedList<patchref_t>();
}