Skip to content
Snippets Groups Projects
Commit 93e72f80 authored by Anton Piccardo-Selg's avatar Anton Piccardo-Selg
Browse files

Refs #15288 Change mutex for ThreadScheduler

parent 39f32529
No related branches found
No related tags found
No related merge requests found
......@@ -150,7 +150,7 @@ public:
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool empty() override {
Mutex::ScopedLock _lock(m_queueLock);
Kernel::LockGuardMutex _lock(m_queueLock);
return m_queue.empty();
}
......@@ -255,7 +255,7 @@ public:
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool empty() override {
Mutex::ScopedLock _lock(m_queueLock);
Kernel::LockGuardMutex _lock(m_queueLock);
return m_map.empty();
}
......
......@@ -33,12 +33,11 @@ public:
//-------------------------------------------------------------------------------
void push(Task *newTask) override {
// Cache the total cost
m_queueLock.lock();
Kernel::LockGuardMutex lock(m_queueLock);
m_cost += newTask->cost();
boost::shared_ptr<Mutex> mut = newTask->getMutex();
m_supermap[mut].emplace(newTask->cost(), newTask);
m_queueLock.unlock();
}
//-------------------------------------------------------------------------------
......@@ -47,7 +46,7 @@ public:
Task *temp = NULL;
m_queueLock.lock();
Kernel::LockGuardMutex lock(m_queueLock);
// Check the size within the same locking block; otherwise the size may
// change before you get the next item.
if (m_supermap.size() > 0) {
......@@ -101,7 +100,6 @@ public:
m_mutexes.insert(mut);
}
m_queueLock.unlock();
return temp;
}
......@@ -115,30 +113,28 @@ public:
UNUSED_ARG(threadnum);
boost::shared_ptr<Mutex> mut = task->getMutex();
if (mut) {
m_queueLock.lock();
Kernel::LockGuardMutex lock(m_queueLock);
// We take this mutex off the list of used ones.
m_mutexes.erase(mut);
m_queueLock.unlock();
}
}
//-------------------------------------------------------------------------------
size_t size() override {
m_queueLock.lock();
Kernel::LockGuardMutex lock(m_queueLock);
// Add up the sizes of all contained maps.
size_t total = 0;
SuperMap::iterator it = m_supermap.begin();
SuperMap::iterator it_end = m_supermap.end();
for (; it != it_end; it++)
total += it->second.size();
m_queueLock.unlock();
return total;
}
//-------------------------------------------------------------------------------
/// @return true if the queue is empty
bool empty() override {
Mutex::ScopedLock _lock(m_queueLock);
Kernel::LockGuardMutex lock(m_queueLock);
SuperMap::iterator it = m_supermap.begin();
SuperMap::iterator it_end = m_supermap.end();
for (; it != it_end; it++)
......@@ -149,7 +145,7 @@ public:
//-------------------------------------------------------------------------------
void clear() override {
m_queueLock.lock();
Kernel::LockGuardMutex lock(m_queueLock);
// Empty out the queue and delete the pointers!
SuperMap::iterator it = m_supermap.begin();
......@@ -165,7 +161,6 @@ public:
m_supermap.clear();
m_cost = 0;
m_costExecuted = 0;
m_queueLock.unlock();
}
protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment