[DEV] try to find android start bug
This commit is contained in:
parent
2b6be85251
commit
a26eb9c92a
@ -26,13 +26,18 @@ void gale::Thread::start() {
|
||||
if (m_state == state_stop) {
|
||||
GALE_DEBUG("Allocate std11::thread [START]");
|
||||
m_state = state_starting;
|
||||
m_thread = new std11::thread(&gale::Thread::threadCall, this);
|
||||
m_thread = new std11::thread(&gale::Thread::threadCall, this, &gale::getContext());
|
||||
if (m_thread == nullptr) {
|
||||
GALE_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
m_thread->detach();
|
||||
GALE_DEBUG("Allocate std11::thread [Set priority]");
|
||||
// set priority
|
||||
|
||||
GALE_DEBUG("Allocate std11::thread [Register context]");
|
||||
// set association with the gale context ...
|
||||
gale::contextRegisterThread(m_thread);
|
||||
//gale::contextRegisterThread(m_thread);
|
||||
|
||||
GALE_DEBUG("Allocate std11::thread [set State]");
|
||||
m_state = state_running;
|
||||
@ -52,7 +57,7 @@ void gale::Thread::stop() {
|
||||
}
|
||||
GALE_DEBUG("stop std11::thread [START]");
|
||||
m_thread->join();
|
||||
gale::contextUnRegisterThread(m_thread);
|
||||
//gale::contextUnRegisterThread(m_thread);
|
||||
GALE_DEBUG("stop std11::thread [delete]");
|
||||
delete m_thread;
|
||||
m_thread = nullptr;
|
||||
@ -61,8 +66,70 @@ void gale::Thread::stop() {
|
||||
GALE_DEBUG("stop std11::thread [STOP]");
|
||||
}
|
||||
|
||||
void gale::Thread::threadCall() {
|
||||
GALE_DEBUG("THREAD MAIN [START]");
|
||||
void gale::Thread::threadCall(gale::Context* _context) {
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
GALE_ERROR("THREAD MAIN [START]");
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
gale::setContext(_context);
|
||||
while (m_state != state_stopping) {
|
||||
if (m_state == state_starting) {
|
||||
GALE_DEBUG("run std11::thread [NOTHING to do]");
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/thread/tools.h>
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
namespace gale {
|
||||
/**
|
||||
@ -39,7 +40,7 @@ namespace gale {
|
||||
void start();
|
||||
void stop();
|
||||
private:
|
||||
void threadCall();
|
||||
void threadCall(gale::Context* _context);
|
||||
protected:
|
||||
virtual bool onThreadCall() { return true; };
|
||||
};
|
||||
|
@ -53,6 +53,7 @@ gale::Context& gale::getContext() {
|
||||
if (it != list.end()) {
|
||||
out = it->second;
|
||||
}
|
||||
|
||||
g_lockContextMap.unlock();
|
||||
#if DEBUG_LEVEL > 2
|
||||
if(out ==nullptr){
|
||||
@ -62,8 +63,9 @@ gale::Context& gale::getContext() {
|
||||
return *out;
|
||||
}
|
||||
|
||||
static void setContext(gale::Context* _context) {
|
||||
void gale::setContext(gale::Context* _context) {
|
||||
std::map<std11::thread::id, gale::Context*>& list = getContextList();
|
||||
GALE_ERROR("Set context : " << std11::this_thread::get_id() << " context pointer : " << uint64_t(_context));
|
||||
g_lockContextMap.lock();
|
||||
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(std11::this_thread::get_id());
|
||||
if (it == list.end()) {
|
||||
@ -80,6 +82,7 @@ void gale::contextRegisterThread(std11::thread* _thread) {
|
||||
}
|
||||
gale::Context* context = &gale::getContext();
|
||||
std::map<std11::thread::id, gale::Context*>& list = getContextList();
|
||||
GALE_ERROR("REGISTER Thread : " << _thread->get_id() << " context pointer : " << uint64_t(context));
|
||||
g_lockContextMap.lock();
|
||||
std::map<std11::thread::id, gale::Context*>::iterator it = list.find(_thread->get_id());
|
||||
if (it == list.end()) {
|
||||
@ -551,7 +554,9 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) {
|
||||
}
|
||||
if( needRedraw == true
|
||||
|| _displayEveryTime == true) {
|
||||
lockContext();
|
||||
m_resourceManager.updateContext();
|
||||
unLockContext();
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystemContext.incrementCounter();
|
||||
}
|
||||
|
@ -301,6 +301,11 @@ namespace gale {
|
||||
* @return current reference on the instance.
|
||||
*/
|
||||
Context& getContext();
|
||||
/**
|
||||
* @brief Set a context of the current thread.
|
||||
* @param[in] _context Current context to associate.
|
||||
*/
|
||||
void setContext(gale::Context* _context);
|
||||
/**
|
||||
* @brief When a new thread is created, it is needed to register it in the gale context interface to permit to get the context associated on it ...
|
||||
* @param[in] _thread generic C++11 thread handle
|
||||
|
Loading…
x
Reference in New Issue
Block a user