[DEV] base of creating periodic real thread event
This commit is contained in:
parent
3b649afbb7
commit
11e7e0f540
@ -130,6 +130,21 @@ void gale::contextUnRegisterThread(std::thread* _thread) {
|
|||||||
g_lockContextMap.unlock();
|
g_lockContextMap.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PeriodicThread : public gale::Thread {
|
||||||
|
public:
|
||||||
|
PeriodicThread() {
|
||||||
|
|
||||||
|
}
|
||||||
|
bool onThreadCall() override {
|
||||||
|
ethread::setName("galeThread 2");
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
|
GALE_INFO("periodicThread");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gale::Context::setInitImage(const std::string& _fileName) {
|
void gale::Context::setInitImage(const std::string& _fileName) {
|
||||||
//m_initDisplayImageName = _fileName;
|
//m_initDisplayImageName = _fileName;
|
||||||
@ -225,6 +240,11 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
|||||||
etk::tool::resetRandom();
|
etk::tool::resetRandom();
|
||||||
// set the curent interface:
|
// set the curent interface:
|
||||||
lockContext();
|
lockContext();
|
||||||
|
// create thread to manage real periodic event
|
||||||
|
m_periodicThread = ememory::makeShared<PeriodicThread>();
|
||||||
|
m_periodicThread->start();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
|
|
||||||
// By default we set 2 themes (1 color and 1 shape ...) :
|
// By default we set 2 themes (1 color and 1 shape ...) :
|
||||||
etk::theme::setNameDefault("GUI", "shape/square/");
|
etk::theme::setNameDefault("GUI", "shape/square/");
|
||||||
etk::theme::setNameDefault("COLOR", "color/black/");
|
etk::theme::setNameDefault("COLOR", "color/black/");
|
||||||
@ -345,6 +365,7 @@ void gale::Context::postAction(std::function<void(gale::Context& _context)> _act
|
|||||||
|
|
||||||
gale::Context::~Context() {
|
gale::Context::~Context() {
|
||||||
GALE_INFO(" == > Gale system Un-Init (BEGIN)");
|
GALE_INFO(" == > Gale system Un-Init (BEGIN)");
|
||||||
|
m_periodicThread->stop();
|
||||||
getResourcesManager().applicationExiting();
|
getResourcesManager().applicationExiting();
|
||||||
// TODO : Clean the message list ...
|
// TODO : Clean the message list ...
|
||||||
// set the curent interface :
|
// set the curent interface :
|
||||||
@ -603,8 +624,19 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) {
|
|||||||
bool needRedraw = false;
|
bool needRedraw = false;
|
||||||
//! Event management section ...
|
//! Event management section ...
|
||||||
{
|
{
|
||||||
// set the curent interface :
|
// set the current interface:
|
||||||
lockContext();
|
lockContext();
|
||||||
|
/*
|
||||||
|
Lock the event processing
|
||||||
|
|
||||||
|
Wait end of current processing
|
||||||
|
|
||||||
|
Display ...
|
||||||
|
|
||||||
|
Release the event processing
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
processEvents();
|
processEvents();
|
||||||
// call all the application for periodic request (the application manage multiple instance ...
|
// call all the application for periodic request (the application manage multiple instance ...
|
||||||
if (m_application != nullptr) {
|
if (m_application != nullptr) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <gale/context/commandLine.hpp>
|
#include <gale/context/commandLine.hpp>
|
||||||
// TODO : #include <gale/context/InputManager.hpp>
|
// TODO : #include <gale/context/InputManager.hpp>
|
||||||
#include <gale/context/Fps.hpp>
|
#include <gale/context/Fps.hpp>
|
||||||
|
#include <gale/Thread.hpp>
|
||||||
#include <ememory/memory.hpp>
|
#include <ememory/memory.hpp>
|
||||||
#include <gale/orientation.hpp>
|
#include <gale/orientation.hpp>
|
||||||
#include <gale/context/clipBoard.hpp>
|
#include <gale/context/clipBoard.hpp>
|
||||||
@ -25,9 +26,11 @@
|
|||||||
#define MAX_MANAGE_INPUT (15)
|
#define MAX_MANAGE_INPUT (15)
|
||||||
|
|
||||||
namespace gale {
|
namespace gale {
|
||||||
|
class Thread;
|
||||||
class Context {
|
class Context {
|
||||||
protected:
|
protected:
|
||||||
std::recursive_mutex m_mutex;
|
std::recursive_mutex m_mutex;
|
||||||
|
ememory::SharedPtr<gale::Thread> m_periodicThread;
|
||||||
private:
|
private:
|
||||||
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
|
ememory::SharedPtr<gale::Application> m_application; //!< Application handle
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user