From 38585d39995ca0580e6de1d2bb8639ca910f53b1 Mon Sep 17 00:00:00 2001 From: vl Date: Mon, 10 May 2010 17:03:26 +0200 Subject: [PATCH] Changed: #865 make the mutex working on Linux --- code/nel/include/nel/misc/mutex.h | 4 ++-- code/nel/include/nel/misc/task_manager.h | 2 +- code/nel/src/misc/async_file_manager.cpp | 8 ++++---- code/nel/src/misc/task_manager.cpp | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/code/nel/include/nel/misc/mutex.h b/code/nel/include/nel/misc/mutex.h index 39432b66c..746f101e3 100644 --- a/code/nel/include/nel/misc/mutex.h +++ b/code/nel/include/nel/misc/mutex.h @@ -611,13 +611,13 @@ public: CAccessor(CUnfairSynchronized *cs) { Synchronized = cs; - const_cast(Synchronized->_Mutex).enter(); + const_cast(Synchronized->_Mutex).enter(); } /// release the mutex ~CAccessor() { - const_cast(Synchronized->_Mutex).leave(); + const_cast(Synchronized->_Mutex).leave(); } /// access to the Value diff --git a/code/nel/include/nel/misc/task_manager.h b/code/nel/include/nel/misc/task_manager.h index c8fbdfbcb..17f20f6c3 100644 --- a/code/nel/include/nel/misc/task_manager.h +++ b/code/nel/include/nel/misc/task_manager.h @@ -140,7 +140,7 @@ protected: /// queue of tasks, using list container instead of queue for DeleteTask methode CSynchronized _RunningTask; - CSynchronized > _TaskQueue; + CUnfairSynchronized > _TaskQueue; CSynchronized > _DoneTaskQueue; /// thread pointer diff --git a/code/nel/src/misc/async_file_manager.cpp b/code/nel/src/misc/async_file_manager.cpp index e7b2bd072..6243e6ea4 100644 --- a/code/nel/src/misc/async_file_manager.cpp +++ b/code/nel/src/misc/async_file_manager.cpp @@ -67,7 +67,7 @@ void CAsyncFileManager::addLoadTask(IRunnable *ploadTask) bool CAsyncFileManager::cancelLoadTask(const CAsyncFileManager::ICancelCallback &callback) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); list &rTaskQueue = acces.value (); list::iterator it = rTaskQueue.begin(); @@ -87,7 +87,7 @@ bool CAsyncFileManager::cancelLoadTask(const CAsyncFileManager::ICancelCallback } // If not found, the current running task may be the one we want to cancel. Must wait it. - // Beware that this code works because of the CSynchronized access we made above (ensure that the + // Beware that this code works because of the CUnfairSynchronized access we made above (ensure that the // taskmanager will end just the current task async (if any) and won't start an other one. waitCurrentTaskToComplete (); @@ -105,7 +105,7 @@ void CAsyncFileManager::loadMesh(const std::string& meshName, IShape **ppShp, ID /* bool CAsyncFileManager::cancelLoadMesh(const std::string& sMeshName) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); list &rTaskQueue = acces.value (); list::iterator it = rTaskQueue.begin(); @@ -167,7 +167,7 @@ void CAsyncFileManager::signal (bool *pSgn) void CAsyncFileManager::cancelSignal (bool *pSgn) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); list &rTaskQueue = acces.value (); list::iterator it = rTaskQueue.begin(); diff --git a/code/nel/src/misc/task_manager.cpp b/code/nel/src/misc/task_manager.cpp index b20aa14bc..a75c931e9 100644 --- a/code/nel/src/misc/task_manager.cpp +++ b/code/nel/src/misc/task_manager.cpp @@ -49,7 +49,7 @@ CTaskManager::~CTaskManager() nlSleep(10); // There should be no remaining Tasks - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); nlassert(acces.value().empty()); _Thread->wait(); delete _Thread; @@ -65,7 +65,7 @@ void CTaskManager::run(void) while(_ThreadRunning) { { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); if(acces.value().empty()) { runnableTask = NULL; @@ -126,14 +126,14 @@ void CTaskManager::run(void) // Add a task to TaskManager void CTaskManager::addTask(IRunnable *r, float priority) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); acces.value().push_back(CWaitingTask(r, priority)); } /// Delete a task, only if task is not running, return true if found and deleted bool CTaskManager::deleteTask(IRunnable *r) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); for(list::iterator it = acces.value().begin(); it != acces.value().end(); it++) { if(it->Task == r) @@ -148,7 +148,7 @@ bool CTaskManager::deleteTask(IRunnable *r) /// Task list size uint CTaskManager::taskListSize(void) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); return acces.value().size(); } @@ -164,7 +164,7 @@ void CTaskManager::waitCurrentTaskToComplete () void CTaskManager::dump (std::vector &result) { CSynchronized::CAccessor accesCurrent(&_RunningTask); - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); CSynchronized >::CAccessor accesDone(&_DoneTaskQueue); const list &taskList = acces.value(); @@ -215,7 +215,7 @@ void CTaskManager::clearDump() uint CTaskManager::getNumWaitingTasks() { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); return acces.value().size(); } @@ -225,7 +225,7 @@ void CTaskManager::changeTaskPriority () { if (_ChangePriorityCallback) { - CSynchronized >::CAccessor acces(&_TaskQueue); + CUnfairSynchronized >::CAccessor acces(&_TaskQueue); list &taskList = acces.value(); list::iterator ite = taskList.begin();