|
@@ -12,8 +12,8 @@ namespace oxygine
|
|
|
|
|
|
|
|
ThreadLoader::~ThreadLoader()
|
|
ThreadLoader::~ThreadLoader()
|
|
|
{
|
|
{
|
|
|
- //if (!pthread_equal(_thread, pthread_self()))
|
|
|
|
|
- // pthread_join(_thread, 0);
|
|
|
|
|
|
|
+ if (!pthread_equal(_thread, pthread_self()))
|
|
|
|
|
+ pthread_join(_thread, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -27,6 +27,11 @@ namespace oxygine
|
|
|
_ress.push_back(res);
|
|
_ress.push_back(res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void ThreadLoader::add(std::function< void() > v)
|
|
|
|
|
+ {
|
|
|
|
|
+ _funcs.push_back(v);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
bool ThreadLoader::isCompleted()
|
|
bool ThreadLoader::isCompleted()
|
|
|
{
|
|
{
|
|
|
return _threadDone;
|
|
return _threadDone;
|
|
@@ -84,6 +89,11 @@ namespace oxygine
|
|
|
res->load();
|
|
res->load();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ for (funcs::iterator i = _funcs.begin(); i != _funcs.end(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ (*i)();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
core::getMainThreadDispatcher().postCallback(0, 0, 0, threadDone, this);
|
|
core::getMainThreadDispatcher().postCallback(0, 0, 0, threadDone, this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -91,6 +101,10 @@ namespace oxygine
|
|
|
{
|
|
{
|
|
|
_threadDone = false;
|
|
_threadDone = false;
|
|
|
addRef();
|
|
addRef();
|
|
|
- pthread_create(&_thread, 0, _staticThreadFunc, this);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ pthread_attr_t attr;
|
|
|
|
|
+ pthread_attr_init(&attr);
|
|
|
|
|
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
|
|
|
|
+ pthread_create(&_thread, &attr, _staticThreadFunc, this);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|