(DEV) Add API to add action in the low level loop
This commit is contained in:
parent
c7be90d128
commit
ac9e861ad6
@ -149,7 +149,10 @@ void gale::Context::processEvents() {
|
|||||||
while (m_msgSystem.count()>0) {
|
while (m_msgSystem.count()>0) {
|
||||||
nbEvent++;
|
nbEvent++;
|
||||||
std::function<void(gale::Context& _context)> func;
|
std::function<void(gale::Context& _context)> func;
|
||||||
m_msgSystem.wait(func);
|
{
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
m_msgSystem.wait(func);
|
||||||
|
}
|
||||||
if (func == nullptr) {
|
if (func == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -302,6 +305,11 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
|||||||
GALE_INFO(" == > Gale system init (END)");
|
GALE_INFO(" == > Gale system init (END)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gale::Context::postAction(std::function<void(gale::Context& _context)> _action) {
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
|
m_msgSystem.post(_action);
|
||||||
|
}
|
||||||
|
|
||||||
gale::Context::~Context() {
|
gale::Context::~Context() {
|
||||||
GALE_INFO(" == > Gale system Un-Init (BEGIN)");
|
GALE_INFO(" == > Gale system Un-Init (BEGIN)");
|
||||||
// TODO : Clean the message list ...
|
// TODO : Clean the message list ...
|
||||||
@ -340,6 +348,7 @@ void gale::Context::requestUpdateSize() {
|
|||||||
m_simulationFile.filePuts(etk::to_string(gale::getTime()));
|
m_simulationFile.filePuts(etk::to_string(gale::getTime()));
|
||||||
m_simulationFile.filePuts(":RECALCULATE_SIZE\n");
|
m_simulationFile.filePuts(":RECALCULATE_SIZE\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([](gale::Context& _context){
|
m_msgSystem.post([](gale::Context& _context){
|
||||||
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||||
_context.forceRedrawAll();
|
_context.forceRedrawAll();
|
||||||
@ -355,6 +364,7 @@ void gale::Context::OS_Resize(const vec2& _size) {
|
|||||||
m_simulationFile.filePuts(etk::to_string(_size));
|
m_simulationFile.filePuts(etk::to_string(_size));
|
||||||
m_simulationFile.filePuts("\n");
|
m_simulationFile.filePuts("\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([_size](gale::Context& _context){
|
m_msgSystem.post([_size](gale::Context& _context){
|
||||||
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
//GALE_DEBUG("Receive MSG : THREAD_RESIZE");
|
||||||
_context.m_windowsSize = _size;
|
_context.m_windowsSize = _size;
|
||||||
@ -368,6 +378,7 @@ void gale::Context::OS_Move(const vec2& _pos) {
|
|||||||
data->TypeMessage = eSystemMessage::msgResize;
|
data->TypeMessage = eSystemMessage::msgResize;
|
||||||
data->resize.w = w;
|
data->resize.w = w;
|
||||||
data->resize.h = h;
|
data->resize.h = h;
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.Post(data);
|
m_msgSystem.Post(data);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -388,6 +399,7 @@ void gale::Context::OS_SetInput(enum gale::key::type _type,
|
|||||||
m_simulationFile.filePuts(etk::to_string(_pos));
|
m_simulationFile.filePuts(etk::to_string(_pos));
|
||||||
m_simulationFile.filePuts("\n");
|
m_simulationFile.filePuts("\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([_type, _status, _pointerID, _pos](gale::Context& _context){
|
m_msgSystem.post([_type, _status, _pointerID, _pos](gale::Context& _context){
|
||||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||||
if (appl == nullptr) {
|
if (appl == nullptr) {
|
||||||
@ -424,6 +436,7 @@ void gale::Context::OS_setKeyboard(const gale::key::Special& _special,
|
|||||||
m_simulationFile.filePuts(etk::to_string(uint64_t(_char)));
|
m_simulationFile.filePuts(etk::to_string(uint64_t(_char)));
|
||||||
m_simulationFile.filePuts("\n");
|
m_simulationFile.filePuts("\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([_special, _type, _state, _char](gale::Context& _context){
|
m_msgSystem.post([_special, _type, _state, _char](gale::Context& _context){
|
||||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||||
if (appl == nullptr) {
|
if (appl == nullptr) {
|
||||||
@ -441,6 +454,7 @@ void gale::Context::OS_Hide() {
|
|||||||
m_simulationFile.filePuts(etk::to_string(gale::getTime()));
|
m_simulationFile.filePuts(etk::to_string(gale::getTime()));
|
||||||
m_simulationFile.filePuts(":VIEW:false\n");
|
m_simulationFile.filePuts(":VIEW:false\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([](gale::Context& _context){
|
m_msgSystem.post([](gale::Context& _context){
|
||||||
/*
|
/*
|
||||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||||
@ -484,6 +498,7 @@ void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardL
|
|||||||
m_simulationFile.filePuts(etk::to_string(_clipboardID));
|
m_simulationFile.filePuts(etk::to_string(_clipboardID));
|
||||||
m_simulationFile.filePuts("\n");
|
m_simulationFile.filePuts("\n");
|
||||||
}
|
}
|
||||||
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
||||||
m_msgSystem.post([_clipboardID](gale::Context& _context){
|
m_msgSystem.post([_clipboardID](gale::Context& _context){
|
||||||
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
ememory::SharedPtr<gale::Application> appl = _context.getApplication();
|
||||||
if (appl != nullptr) {
|
if (appl != nullptr) {
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
namespace gale {
|
namespace gale {
|
||||||
class Context/* : private gale::object::RemoveEvent */{
|
class Context/* : private gale::object::RemoveEvent */{
|
||||||
|
protected:
|
||||||
|
std::recursive_mutex m_mutex;
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
|
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
|
||||||
public:
|
public:
|
||||||
@ -75,6 +77,8 @@ namespace gale {
|
|||||||
*/
|
*/
|
||||||
void processEvents();
|
void processEvents();
|
||||||
public:
|
public:
|
||||||
|
void postAction(std::function<void(gale::Context& _context)> _action);
|
||||||
|
public:
|
||||||
|
|
||||||
virtual void setArchiveDir(int _mode, const char* _str, const char* _applName=nullptr);
|
virtual void setArchiveDir(int _mode, const char* _str, const char* _applName=nullptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user