mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
Changed: #865 make the mutex working on Linux
This commit is contained in:
parent
3b33efae5c
commit
86eb5705d9
4 changed files with 15 additions and 15 deletions
|
@ -611,13 +611,13 @@ public:
|
||||||
CAccessor(CUnfairSynchronized<T> *cs)
|
CAccessor(CUnfairSynchronized<T> *cs)
|
||||||
{
|
{
|
||||||
Synchronized = cs;
|
Synchronized = cs;
|
||||||
const_cast<CMutex&>(Synchronized->_Mutex).enter();
|
const_cast<CUnfairMutex&>(Synchronized->_Mutex).enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// release the mutex
|
/// release the mutex
|
||||||
~CAccessor()
|
~CAccessor()
|
||||||
{
|
{
|
||||||
const_cast<CMutex&>(Synchronized->_Mutex).leave();
|
const_cast<CUnfairMutex&>(Synchronized->_Mutex).leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// access to the Value
|
/// access to the Value
|
||||||
|
|
|
@ -140,7 +140,7 @@ protected:
|
||||||
|
|
||||||
/// queue of tasks, using list container instead of queue for DeleteTask methode
|
/// queue of tasks, using list container instead of queue for DeleteTask methode
|
||||||
CSynchronized<std::string> _RunningTask;
|
CSynchronized<std::string> _RunningTask;
|
||||||
CSynchronized<std::list<CWaitingTask> > _TaskQueue;
|
CUnfairSynchronized<std::list<CWaitingTask> > _TaskQueue;
|
||||||
CSynchronized<std::deque<std::string> > _DoneTaskQueue;
|
CSynchronized<std::deque<std::string> > _DoneTaskQueue;
|
||||||
|
|
||||||
/// thread pointer
|
/// thread pointer
|
||||||
|
|
|
@ -67,7 +67,7 @@ void CAsyncFileManager::addLoadTask(IRunnable *ploadTask)
|
||||||
|
|
||||||
bool CAsyncFileManager::cancelLoadTask(const CAsyncFileManager::ICancelCallback &callback)
|
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> &rTaskQueue = acces.value ();
|
||||||
list<CWaitingTask>::iterator it = rTaskQueue.begin();
|
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.
|
// 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.
|
// taskmanager will end just the current task async (if any) and won't start an other one.
|
||||||
waitCurrentTaskToComplete ();
|
waitCurrentTaskToComplete ();
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void CAsyncFileManager::loadMesh(const std::string& meshName, IShape **ppShp, ID
|
||||||
/*
|
/*
|
||||||
bool CAsyncFileManager::cancelLoadMesh(const std::string& sMeshName)
|
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*> &rTaskQueue = acces.value ();
|
||||||
list<IRunnable*>::iterator it = rTaskQueue.begin();
|
list<IRunnable*>::iterator it = rTaskQueue.begin();
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void CAsyncFileManager::signal (bool *pSgn)
|
||||||
|
|
||||||
void CAsyncFileManager::cancelSignal (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> &rTaskQueue = acces.value ();
|
||||||
list<CWaitingTask>::iterator it = rTaskQueue.begin();
|
list<CWaitingTask>::iterator it = rTaskQueue.begin();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ CTaskManager::~CTaskManager()
|
||||||
nlSleep(10);
|
nlSleep(10);
|
||||||
|
|
||||||
// There should be no remaining Tasks
|
// There should be no remaining Tasks
|
||||||
CSynchronized<std::list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<std::list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
nlassert(acces.value().empty());
|
nlassert(acces.value().empty());
|
||||||
_Thread->wait();
|
_Thread->wait();
|
||||||
delete _Thread;
|
delete _Thread;
|
||||||
|
@ -65,7 +65,7 @@ void CTaskManager::run(void)
|
||||||
while(_ThreadRunning)
|
while(_ThreadRunning)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
if(acces.value().empty())
|
if(acces.value().empty())
|
||||||
{
|
{
|
||||||
runnableTask = NULL;
|
runnableTask = NULL;
|
||||||
|
@ -126,14 +126,14 @@ void CTaskManager::run(void)
|
||||||
// Add a task to TaskManager
|
// Add a task to TaskManager
|
||||||
void CTaskManager::addTask(IRunnable *r, float priority)
|
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));
|
acces.value().push_back(CWaitingTask(r, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete a task, only if task is not running, return true if found and deleted
|
/// Delete a task, only if task is not running, return true if found and deleted
|
||||||
bool CTaskManager::deleteTask(IRunnable *r)
|
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++)
|
for(list<CWaitingTask>::iterator it = acces.value().begin(); it != acces.value().end(); it++)
|
||||||
{
|
{
|
||||||
if(it->Task == r)
|
if(it->Task == r)
|
||||||
|
@ -148,7 +148,7 @@ bool CTaskManager::deleteTask(IRunnable *r)
|
||||||
/// Task list size
|
/// Task list size
|
||||||
uint CTaskManager::taskListSize(void)
|
uint CTaskManager::taskListSize(void)
|
||||||
{
|
{
|
||||||
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
return acces.value().size();
|
return acces.value().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ void CTaskManager::waitCurrentTaskToComplete ()
|
||||||
void CTaskManager::dump (std::vector<std::string> &result)
|
void CTaskManager::dump (std::vector<std::string> &result)
|
||||||
{
|
{
|
||||||
CSynchronized<string>::CAccessor accesCurrent(&_RunningTask);
|
CSynchronized<string>::CAccessor accesCurrent(&_RunningTask);
|
||||||
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
CSynchronized<deque<string> >::CAccessor accesDone(&_DoneTaskQueue);
|
CSynchronized<deque<string> >::CAccessor accesDone(&_DoneTaskQueue);
|
||||||
|
|
||||||
const list<CWaitingTask> &taskList = acces.value();
|
const list<CWaitingTask> &taskList = acces.value();
|
||||||
|
@ -215,7 +215,7 @@ void CTaskManager::clearDump()
|
||||||
|
|
||||||
uint CTaskManager::getNumWaitingTasks()
|
uint CTaskManager::getNumWaitingTasks()
|
||||||
{
|
{
|
||||||
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
return acces.value().size();
|
return acces.value().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void CTaskManager::changeTaskPriority ()
|
||||||
{
|
{
|
||||||
if (_ChangePriorityCallback)
|
if (_ChangePriorityCallback)
|
||||||
{
|
{
|
||||||
CSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
CUnfairSynchronized<list<CWaitingTask> >::CAccessor acces(&_TaskQueue);
|
||||||
list<CWaitingTask> &taskList = acces.value();
|
list<CWaitingTask> &taskList = acces.value();
|
||||||
|
|
||||||
list<CWaitingTask>::iterator ite = taskList.begin();
|
list<CWaitingTask>::iterator ite = taskList.begin();
|
||||||
|
|
Loading…
Reference in a new issue