This refactor the StandAlone and WorkList files in order to use more
C++11 features remove the dependencies from OS specific code. Changes: - Making WorkList class to have its own mutex instead of the OS specific global one. The new mutex is the one from std library. The OS specific code is also removed. - Using the C++11 std library to handle threads in StandAlone application and enabling concurrent processing on non-windows platforms. - converting the global variable Worklist into local variable workList.
This commit is contained in:
@@ -36,8 +36,9 @@
|
||||
#define WORKLIST_H_INCLUDED
|
||||
|
||||
#include "../glslang/OSDependent/osinclude.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace glslang {
|
||||
|
||||
@@ -58,24 +59,19 @@ namespace glslang {
|
||||
|
||||
void add(TWorkItem* item)
|
||||
{
|
||||
GetGlobalLock();
|
||||
|
||||
std::lock_guard<std::mutex> guard(mutex);
|
||||
worklist.push_back(item);
|
||||
|
||||
ReleaseGlobalLock();
|
||||
}
|
||||
|
||||
bool remove(TWorkItem*& item)
|
||||
{
|
||||
GetGlobalLock();
|
||||
std::lock_guard<std::mutex> guard(mutex);
|
||||
|
||||
if (worklist.empty())
|
||||
return false;
|
||||
item = worklist.front();
|
||||
worklist.pop_front();
|
||||
|
||||
ReleaseGlobalLock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,6 +86,7 @@ namespace glslang {
|
||||
}
|
||||
|
||||
protected:
|
||||
std::mutex mutex;
|
||||
std::list<TWorkItem*> worklist;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user