Changed: #865 make the mutex working on Linux

This commit is contained in:
vl 2010-05-10 17:03:26 +02:00
parent bb97e2a719
commit 38585d3999
4 changed files with 15 additions and 15 deletions

View file

@ -611,13 +611,13 @@ public:
CAccessor(CUnfairSynchronized<T> *cs)
{
Synchronized = cs;
const_cast<CMutex&>(Synchronized->_Mutex).enter();
const_cast<CUnfairMutex&>(Synchronized->_Mutex).enter();
}
/// release the mutex
~CAccessor()
{
const_cast<CMutex&>(Synchronized->_Mutex).leave();
const_cast<CUnfairMutex&>(Synchronized->_Mutex).leave();
}
/// access to the Value

View file

@ -140,7 +140,7 @@ protected:
/// queue of tasks, using list container instead of queue for DeleteTask methode
CSynchronized<std::string> _RunningTask;
CSynchronized<std::list<CWaitingTask> > _TaskQueue;
CUnfairSynchronized<std::list<CWaitingTask> > _TaskQueue;
CSynchronized<std::deque<std::string> > _DoneTaskQueue;
/// thread pointer

View file

@ -67,7 +67,7 @@ void CAsyncFileManager::addLoadTask(IRunnable *ploadTask)
bool CAsyncFileManager::cancelLoadTask(const CAsyncFileManager::ICancelCallback &callback)
{
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
list<CWaitingTask> &rTaskQueue = acces.value ();
list<CWaitingTask>::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<list<IRunnable *> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<IRunnable *> >::CAccessor acces(&_TaskQueue);
list<IRunnable*> &rTaskQueue = acces.value ();
list<IRunnable*>::iterator it = rTaskQueue.begin();
@ -167,7 +167,7 @@ void CAsyncFileManager::signal (bool *pSgn)
void CAsyncFileManager::cancelSignal (bool *pSgn)
{
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
list<CWaitingTask> &rTaskQueue = acces.value ();
list<CWaitingTask>::iterator it = rTaskQueue.begin();

View file

@ -49,7 +49,7 @@ CTaskManager::~CTaskManager()
nlSleep(10);
// There should be no remaining Tasks
CSynchronized<std::list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<std::list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
nlassert(acces.value().empty());
_Thread->wait();
delete _Thread;
@ -65,7 +65,7 @@ void CTaskManager::run(void)
while(_ThreadRunning)
{
{
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::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<std::list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<std::list<CWaitingTask> >::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<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
for(list<CWaitingTask>::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<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
return acces.value().size();
}
@ -164,7 +164,7 @@ void CTaskManager::waitCurrentTaskToComplete ()
void CTaskManager::dump (std::vector<std::string> &result)
{
CSynchronized<string>::CAccessor accesCurrent(&_RunningTask);
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CSynchronized<deque<string> >::CAccessor accesDone(&_DoneTaskQueue);
const list<CWaitingTask> &taskList = acces.value();
@ -215,7 +215,7 @@ void CTaskManager::clearDump()
uint CTaskManager::getNumWaitingTasks()
{
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
return acces.value().size();
}
@ -225,7 +225,7 @@ void CTaskManager::changeTaskPriority ()
{
if (_ChangePriorityCallback)
{
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
list<CWaitingTask> &taskList = acces.value();
list<CWaitingTask>::iterator ite = taskList.begin();