[DEV] update to the new ETK allocator wrapper

This commit is contained in:
Edouard DUPIN 2017-10-21 19:05:21 +02:00
parent e8a09ef7d2
commit 1d791be465
14 changed files with 36 additions and 15 deletions

View File

@ -35,7 +35,7 @@ namespace appl {
m_interface.link(); m_interface.link();
m_threadRunning = true; m_threadRunning = true;
APPL_INFO("Start waiting on " << _host << " " << _port); APPL_INFO("Start waiting on " << _host << " " << _port);
m_thread = new ethread::Thread([&](){ threadCallback();}, "GatewayListening"); m_thread = ETK_NEW(ethread::Thread, [&](){ threadCallback();}, "GatewayListening");
if (m_thread == nullptr) { if (m_thread == nullptr) {
m_threadRunning = false; m_threadRunning = false;
APPL_ERROR("creating callback thread!"); APPL_ERROR("creating callback thread!");
@ -49,7 +49,7 @@ namespace appl {
m_interface.unlink(); m_interface.unlink();
if (m_thread != nullptr) { if (m_thread != nullptr) {
m_thread->join(); m_thread->join();
delete m_thread; ETK_DELETE(ethread::Thread, m_thread);
m_thread = nullptr; m_thread = nullptr;
} }
} }

View File

@ -8,6 +8,7 @@
#include <appl/GateWay.hpp> #include <appl/GateWay.hpp>
#include <etk/etk.hpp> #include <etk/etk.hpp>
#include <zeus/zeus.hpp> #include <zeus/zeus.hpp>
#include <etk/Allocator.hpp>
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
@ -246,7 +247,7 @@ int main(int _argc, const char *_argv[]) {
} }
} }
#endif #endif
int32_t countMemeCheck = 0;
APPL_INFO("=================================="); APPL_INFO("==================================");
APPL_INFO("== ZEUS gateway start =="); APPL_INFO("== ZEUS gateway start ==");
APPL_INFO("=================================="); APPL_INFO("==================================");
@ -258,6 +259,10 @@ int main(int _argc, const char *_argv[]) {
while (routerAlive == true) { while (routerAlive == true) {
ethread::sleepMilliSeconds((100)); ethread::sleepMilliSeconds((100));
basicGateway.cleanIO(); basicGateway.cleanIO();
if (countMemeCheck++ >= 200) {
countMemeCheck = 0;
ETK_MEM_SHOW_LOG(true);
}
routerAlive = basicGateway.checkIsAlive(echrono::seconds(routerDisconnectionDelay)); routerAlive = basicGateway.checkIsAlive(echrono::seconds(routerDisconnectionDelay));
if (routerAlive == false) { if (routerAlive == false) {
APPL_WARNING("Router is Dead or Timeout"); APPL_WARNING("Router is Dead or Timeout");
@ -315,6 +320,10 @@ int main(int _argc, const char *_argv[]) {
} else { } else {
elog::flush(); elog::flush();
ethread::sleepMilliSeconds(1000); ethread::sleepMilliSeconds(1000);
if (countMemeCheck++ >= 20) {
countMemeCheck = 0;
ETK_MEM_SHOW_LOG(true);
}
APPL_INFO("gateway in waiting ... " << iii << "/inf"); APPL_INFO("gateway in waiting ... " << iii << "/inf");
} }
iii++; iii++;

View File

@ -5,6 +5,7 @@
*/ */
#include <appl/debug.hpp> #include <appl/debug.hpp>
#include <etk/Allocator.hpp>
#include <etk/etk.hpp> #include <etk/etk.hpp>
#include <ethread/Mutex.hpp> #include <ethread/Mutex.hpp>
@ -173,6 +174,7 @@ int main(int _argc, const char *_argv[]) {
it->publish(m_client); it->publish(m_client);
} }
uint32_t iii = 0; uint32_t iii = 0;
int32_t countMemeCheck = 0;
while(m_client.isAlive() == true) { while(m_client.isAlive() == true) {
m_client.pingIsAlive(); m_client.pingIsAlive();
m_client.displayConnectedObject(); m_client.displayConnectedObject();
@ -181,6 +183,10 @@ int main(int _argc, const char *_argv[]) {
it->peridic_call(); it->peridic_call();
} }
ethread::sleepMilliSeconds(1000); ethread::sleepMilliSeconds(1000);
if (countMemeCheck++ >= 20) {
countMemeCheck = 0;
ETK_MEM_SHOW_LOG(true);
}
APPL_INFO("service in waiting ... " << iii << "/inf"); APPL_INFO("service in waiting ... " << iii << "/inf");
iii++; iii++;
} }

View File

@ -108,6 +108,6 @@ int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv); etk::init(_argc, _argv);
audio::river::init(); audio::river::init();
zeus::init(_argc, _argv); zeus::init(_argc, _argv);
return ewol::run(new appl::MainApplication(), _argc, _argv); return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
} }

View File

@ -87,7 +87,7 @@ namespace appl {
m_interface.setPort(_port); m_interface.setPort(_port);
m_interface.link(); m_interface.link();
m_threadRunning = true; m_threadRunning = true;
m_thread = new ethread::Thread([&](){ threadCallback();}, "routerListener"); m_thread = ETK_NEW(ethread::Thread, [&](){ threadCallback();}, "routerListener");
if (m_thread == nullptr) { if (m_thread == nullptr) {
m_threadRunning = false; m_threadRunning = false;
ZEUS_ERROR("creating callback thread!"); ZEUS_ERROR("creating callback thread!");
@ -101,7 +101,7 @@ namespace appl {
m_interface.unlink(); m_interface.unlink();
if (m_thread != nullptr) { if (m_thread != nullptr) {
m_thread->join(); m_thread->join();
delete m_thread; ETK_DELETE(ethread::Thread, m_thread);
m_thread = nullptr; m_thread = nullptr;
} }
} }

View File

@ -8,6 +8,7 @@
#include <appl/Router.hpp> #include <appl/Router.hpp>
#include <etk/etk.hpp> #include <etk/etk.hpp>
#include <zeus/zeus.hpp> #include <zeus/zeus.hpp>
#include <etk/Allocator.hpp>
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
@ -57,9 +58,14 @@ int main(int _argc, const char *_argv[]) {
APPL_INFO("== ZEUS router start =="); APPL_INFO("== ZEUS router start ==");
APPL_INFO("=================================="); APPL_INFO("==================================");
basicRouter.start(); basicRouter.start();
int32_t countMemeCheck = 0;
while (true) { while (true) {
ethread::sleepMilliSeconds((100)); ethread::sleepMilliSeconds((100));
basicRouter.cleanIO(); basicRouter.cleanIO();
if (countMemeCheck++ >= 200) {
countMemeCheck = 0;
ETK_MEM_SHOW_LOG(true);
}
} }
basicRouter.stop(); basicRouter.stop();
APPL_INFO("=================================="); APPL_INFO("==================================");

View File

@ -56,6 +56,6 @@ namespace appl {
int main(int _argc, const char *_argv[]) { int main(int _argc, const char *_argv[]) {
audio::river::init(); audio::river::init();
zeus::init(_argc, _argv); zeus::init(_argc, _argv);
return ewol::run(new appl::MainApplication(), _argc, _argv); return ewol::run(ETK_NEW(appl::MainApplication)(), _argc, _argv);
} }

View File

@ -183,7 +183,7 @@ bool zeus::WebServer::isActive() const {
void zeus::WebServer::connect(bool _async){ void zeus::WebServer::connect(bool _async){
ZEUS_DEBUG("connect [START]"); ZEUS_DEBUG("connect [START]");
m_threadAsyncRunning = true; m_threadAsyncRunning = true;
m_threadAsync = new ethread::Thread([&](){ threadAsyncCallback();}, "webServerAsync"); m_threadAsync = ETK_NEW(ethread::Thread, [&](){ threadAsyncCallback();}, "webServerAsync");
if (m_threadAsync == nullptr) { if (m_threadAsync == nullptr) {
m_threadAsyncRunning = false; m_threadAsyncRunning = false;
ZEUS_ERROR("creating async sender thread!"); ZEUS_ERROR("creating async sender thread!");
@ -211,7 +211,7 @@ void zeus::WebServer::disconnect(bool _inThreadStop){
m_connection.stop(_inThreadStop); m_connection.stop(_inThreadStop);
if (m_threadAsync != nullptr) { if (m_threadAsync != nullptr) {
m_threadAsync->join(); m_threadAsync->join();
delete m_threadAsync; ETK_DELETE(ethread::Thread, m_threadAsync);
m_threadAsync = nullptr; m_threadAsync = nullptr;
} }
ZEUS_DEBUG("disconnect [STOP]"); ZEUS_DEBUG("disconnect [STOP]");

View File

@ -89,6 +89,6 @@ void zeus::message::Answer::appendMessageData(ememory::SharedPtr<zeus::message::
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::message::Answer> zeus::message::Answer::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::message::Answer> zeus::message::Answer::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::message::Answer>(new zeus::message::Answer(_iface)); return ememory::SharedPtr<zeus::message::Answer>(ETK_NEW(zeus::message::Answer, _iface));
} }

View File

@ -74,5 +74,5 @@ void zeus::message::Call::appendMessageData(ememory::SharedPtr<zeus::message::Da
ememory::SharedPtr<zeus::message::Call> zeus::message::Call::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::message::Call> zeus::message::Call::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::message::Call>(new zeus::message::Call(_iface)); return ememory::SharedPtr<zeus::message::Call>(ETK_NEW(zeus::message::Call, _iface));
} }

View File

@ -71,5 +71,5 @@ void zeus::message::Data::composeWith(const uint8_t* _buffer, uint32_t _lenght)
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::message::Data> zeus::message::Data::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::message::Data> zeus::message::Data::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::message::Data>(new zeus::message::Data(_iface)); return ememory::SharedPtr<zeus::message::Data>(ETK_NEW(zeus::message::Data, _iface));
} }

View File

@ -44,6 +44,6 @@ void zeus::message::Event::composeWith(const uint8_t* _buffer, uint32_t _lenght)
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::message::Event> zeus::message::Event::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::message::Event> zeus::message::Event::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::message::Event>(new zeus::message::Event(_iface)); return ememory::SharedPtr<zeus::message::Event>(ETK_NEW(zeus::message::Event, _iface));
} }

View File

@ -16,7 +16,7 @@
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::MessageFlow> zeus::MessageFlow::create() { ememory::SharedPtr<zeus::MessageFlow> zeus::MessageFlow::create() {
return ememory::SharedPtr<zeus::MessageFlow>(new zeus::MessageFlow); return ememory::SharedPtr<zeus::MessageFlow>(ETK_NEW(zeus::MessageFlow));
} }
*/ */

View File

@ -190,7 +190,7 @@ enum zeus::message::type zeus::Message::getType() const {
// -- Factory // -- Factory
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface) { ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface) {
return ememory::SharedPtr<zeus::Message>(new zeus::Message(_iface)); return ememory::SharedPtr<zeus::Message>(ETK_NEW(zeus::Message, _iface));
} }
ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const etk::Vector<uint8_t>& _buffer) { ememory::SharedPtr<zeus::Message> zeus::Message::create(ememory::SharedPtr<zeus::WebServer> _iface, const etk::Vector<uint8_t>& _buffer) {