diff --git a/test/service1/appl/main-service-test-service1.cpp b/test/service1/appl/main-service-test-service1.cpp index 81acdac..5c1d591 100644 --- a/test/service1/appl/main-service-test-service1.cpp +++ b/test/service1/appl/main-service-test-service1.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ #include #include -static std::mutex g_mutex; +static ethread::Mutex g_mutex; static etk::String g_basePath; static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; @@ -96,7 +96,7 @@ static void load_db() { ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_INFO("Load USER: " << g_basePath); load_db(); APPL_INFO("new USER: [STOP]"); @@ -104,7 +104,7 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String } ETK_EXPORT_API bool SERVICE_IO_uninit() { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); store_db(); APPL_INFO("delete USER [STOP]"); return true; diff --git a/tools/gateway/appl/GateWay.cpp b/tools/gateway/appl/GateWay.cpp index b3ebdea..c3e5141 100644 --- a/tools/gateway/appl/GateWay.cpp +++ b/tools/gateway/appl/GateWay.cpp @@ -15,7 +15,7 @@ namespace appl { class TcpServerInput { private: enet::TcpServer m_interface; - std::thread* m_thread; + ethread::Thread* m_thread; bool m_threadRunning; appl::GateWay* m_gateway; public: @@ -32,7 +32,7 @@ namespace appl { m_interface.link(); m_threadRunning = true; APPL_INFO("Start waiting on " << _host << " " << _port); - m_thread = new std::thread([&](void *){ this->threadCallback();}, nullptr); + m_thread = new ethread::Thread([&](void *){ this->threadCallback();}, nullptr); if (m_thread == nullptr) { m_threadRunning = false; APPL_ERROR("creating callback thread!"); diff --git a/tools/gateway/appl/main-gateway.cpp b/tools/gateway/appl/main-gateway.cpp index 7676943..1ee067d 100644 --- a/tools/gateway/appl/main-gateway.cpp +++ b/tools/gateway/appl/main-gateway.cpp @@ -15,13 +15,13 @@ #define GATEWAY_ENABLE_LAUNCHER #ifdef GATEWAY_ENABLE_LAUNCHER -#include +#include #include #include #include #include #include -#include +#include #include #include #include diff --git a/tools/launcher/appl/main-launcher.cpp b/tools/launcher/appl/main-launcher.cpp index 4281116..bea8c24 100644 --- a/tools/launcher/appl/main-launcher.cpp +++ b/tools/launcher/appl/main-launcher.cpp @@ -7,13 +7,13 @@ #include #include -#include +#include #include #include #include #include #include -#include +#include #include #include #include diff --git a/tools/player-video/appl/MediaDecoder.cpp b/tools/player-video/appl/MediaDecoder.cpp index cf6f555..ba17144 100644 --- a/tools/player-video/appl/MediaDecoder.cpp +++ b/tools/player-video/appl/MediaDecoder.cpp @@ -490,7 +490,7 @@ int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) { } // Real Load of the data: { - std::unique_lock lock(m_remote->m_mutex); + std::unique_lock lock(m_remote->m_mutex); memcpy(_buf, &m_remote->m_buffer[m_remote->m_bufferReadPosition], _bufSize); m_remote->m_bufferReadPosition += _bufSize; } @@ -499,7 +499,7 @@ int appl::MediaDecoder::readFunc(uint8_t* _buf, int _bufSize) { } int32_t appl::StreamBuffering::sizeReadable() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); for (auto &it : m_bufferFillSection) { if ( m_bufferReadPosition >= it.first && m_bufferReadPosition < it.second) { @@ -561,7 +561,7 @@ bool appl::StreamBuffering::addDataCallback(const zeus::Raw& _data, int64_t _pos std::this_thread::sleep_for(std::chrono::milliseconds(10)); #endif { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); bool find = false; m_callInProgress = false; // TODO : Check buffer size ... @@ -609,24 +609,24 @@ bool appl::StreamBuffering::addDataCallback(const zeus::Raw& _data, int64_t _pos appl::StreamBuffering::StreamBuffering() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callInProgress = false; m_stopRequested = false; m_mediaId = 0; m_bufferReadPosition = 0; } void appl::StreamBuffering::stopStream() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_stopRequested = true; } void appl::StreamBuffering::startStream() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_stopRequested = false; } // TODO: Add requested section ... void appl::StreamBuffering::checkIfWeNeedMoreDataFromNetwork() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); // check if enought data: bool find = false; if (m_callInProgress == true) { diff --git a/tools/player-video/appl/MediaDecoder.hpp b/tools/player-video/appl/MediaDecoder.hpp index c9e126e..9979782 100644 --- a/tools/player-video/appl/MediaDecoder.hpp +++ b/tools/player-video/appl/MediaDecoder.hpp @@ -60,7 +60,7 @@ namespace appl { class StreamBuffering : public ememory::EnableSharedFromThis { public: StreamBuffering(); - std::mutex m_mutex; //!< local Lock Data protection + ethread::Mutex m_mutex; //!< local Lock Data protection ememory::SharedPtr m_property; //!< Remote interface that must get data uint32_t m_mediaId; //!< remote media ID that need to get data zeus::ProxyFile m_fileHandle; //!< Reference on the remote file @@ -73,11 +73,11 @@ namespace appl { bool addDataCallback(const zeus::Raw& _data, int64_t _positionRequest); void checkIfWeNeedMoreDataFromNetwork(); uint64_t getSize() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_buffer.size(); } etk::Vector> getDownloadPart() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_bufferFillSection; } int32_t sizeReadable(); diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index 011376c..cc8d156 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -70,7 +70,7 @@ void appl::widget::ListViewer::searchElements(etk::String _filter) { void appl::ElementProperty::loadData() { // Check progression status: { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_metadataUpdated != appl::statusLoadingData::noData) { return; } @@ -83,7 +83,7 @@ void appl::ElementProperty::loadData() { futMedia.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get media error: " << tmpProperty->m_id); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_title = "[ERROR] can not get media informations
" + _error + ": " + _help; tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; } @@ -95,7 +95,7 @@ void appl::ElementProperty::loadData() { if (_media.exist() == false) { APPL_ERROR("get media error"); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_title = "[ERROR] can not get media informations (2)"; tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; } @@ -105,7 +105,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("title") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -116,12 +116,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get title: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_title = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -132,7 +132,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("series-name") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -143,12 +143,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get serie: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_serie = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -159,7 +159,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("saison") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -170,12 +170,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get saison: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_saison = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -186,7 +186,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("episode") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -197,12 +197,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get episode: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_episode = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -214,7 +214,7 @@ void appl::ElementProperty::loadData() { .andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO("Get remot error : " << _error << " " << _help); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -225,12 +225,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get description: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_description = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -241,7 +241,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("production-methode") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -252,12 +252,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get production-methode: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_productMethode = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -268,7 +268,7 @@ void appl::ElementProperty::loadData() { _media.getMetadata("type") .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -279,12 +279,12 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get type: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_type = _value; } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -295,7 +295,7 @@ void appl::ElementProperty::loadData() { _media.getMineType() .andElse([=](const etk::String& _error, const etk::String& _help) mutable { { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -306,7 +306,7 @@ void appl::ElementProperty::loadData() { .andThen([=](etk::String _value) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get mine-type: " << _value); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_mineType = _value; if (etk::start_with(tmpProperty->m_mineType, "video") == true) { // TODO : Optimise this ... @@ -318,7 +318,7 @@ void appl::ElementProperty::loadData() { } m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -336,7 +336,7 @@ void appl::ElementProperty::loadData() { std::this_thread::sleep_for(std::chrono::milliseconds(400)); etk::String serie; { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); serie = tmpProperty->m_serie; } if (serie != "") { @@ -345,7 +345,7 @@ void appl::ElementProperty::loadData() { APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group error: " << serie << ": " << _help); { m_widget->markToRedraw(); - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -361,14 +361,14 @@ void appl::ElementProperty::loadData() { etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover Group on: " << serie << " mineType '" << mineType << "'"); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_thumb = egami::load(mineType, bufferData); tmpProperty->m_thumbPresent = true; } APPL_WARNING("Get the Thumb ... " << tmpProperty->m_title << " ==> " << tmpProperty->m_thumb); m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -378,7 +378,7 @@ void appl::ElementProperty::loadData() { }); } else { m_widget->markToRedraw(); - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -394,14 +394,14 @@ void appl::ElementProperty::loadData() { etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on: " << tmpProperty->m_id << " mineType '" << mineType << "'"); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_thumb = egami::load(mineType, bufferData); tmpProperty->m_thumbPresent = true; } APPL_WARNING("Get the Thumb ... " << tmpProperty->m_title << " ==> " << tmpProperty->m_thumb); m_widget->markToRedraw(); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_nbElementLoaded++; if (tmpProperty->m_nbElementLoaded >= nbCallOfMetaData) { tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; @@ -412,13 +412,13 @@ void appl::ElementProperty::loadData() { } bool appl::ElementProperty::LoadDataEnded() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_metadataUpdated == appl::statusLoadingData::done; } void appl::ElementPropertyGroup::loadData() { // Check progression status: { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_metadataUpdated != appl::statusLoadingData::noData) { return; } @@ -430,7 +430,7 @@ void appl::ElementPropertyGroup::loadData() { futMedia.andElse([=](const etk::String& _error, const etk::String& _help) mutable { APPL_INFO(" [" << tmpProperty->m_id << "] get cover error on group: " << tmpProperty->m_title << ": " << _help); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; } m_widget->markToRedraw(); @@ -444,7 +444,7 @@ void appl::ElementPropertyGroup::loadData() { etk::String mineType = mineTypeFut.wait().get(); APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " mineType '" << mineType << "'"); { - std::unique_lock lock(tmpProperty->m_mutex); + std::unique_lock lock(tmpProperty->m_mutex); tmpProperty->m_thumb = egami::load(mineType, bufferData); tmpProperty->m_thumbPresent = true; } @@ -456,7 +456,7 @@ void appl::ElementPropertyGroup::loadData() { } bool appl::ElementPropertyGroup::LoadDataEnded() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_metadataUpdated == appl::statusLoadingData::done; } @@ -775,7 +775,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { if (m_property->LoadDataEnded() == false) { textToDisplay += "
Loading in progress ... " + etk::toString(m_property->m_nbElementLoaded) + "/8"; } else { - std::unique_lock lock(m_property->m_mutex); + std::unique_lock lock(m_property->m_mutex); //m_text.setClipping(drawClippingPos, drawClippingSize); textToDisplay = "" + m_property->m_title + "
"; bool newLine = false; @@ -821,7 +821,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { haveThumb = false; m_image.setSource("DATA:Home.svg", 128); } else { - std::unique_lock lock(m_property->m_mutex); + std::unique_lock lock(m_property->m_mutex); if (m_property->m_thumbPresent == true) { haveThumb = true; m_image.setSource(m_property->m_thumb); @@ -847,7 +847,7 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { if (m_propertyGroup->LoadDataEnded() == false) { haveThumb = false; } else { - std::unique_lock lock(m_propertyGroup->m_mutex); + std::unique_lock lock(m_propertyGroup->m_mutex); if (m_propertyGroup->m_thumbPresent == true) { haveThumb = true; m_image.setSource(m_propertyGroup->m_thumb); diff --git a/tools/player-video/appl/widget/ListViewer.hpp b/tools/player-video/appl/widget/ListViewer.hpp index 51b6d8f..e97b0ea 100644 --- a/tools/player-video/appl/widget/ListViewer.hpp +++ b/tools/player-video/appl/widget/ListViewer.hpp @@ -41,7 +41,7 @@ namespace appl { uint32_t m_nbElementLoaded; //!< this cont the number of lement loaded to set tle media full loaded public: bool LoadDataEnded(); - std::mutex m_mutex; + ethread::Mutex m_mutex; uint64_t m_id; //!< Remote Id of the Media egami::Image m_thumb; //!< simple image describing the element @@ -77,7 +77,7 @@ namespace appl { public: bool LoadDataEnded(); public: - std::mutex m_mutex; + ethread::Mutex m_mutex; uint64_t m_id; //!< Remote Id of the Media etk::String m_title; //!< Title of the Group etk::String m_filter; //!< element to add in the filter diff --git a/tools/router/appl/Router.cpp b/tools/router/appl/Router.cpp index 6a6b788..bb8b906 100644 --- a/tools/router/appl/Router.cpp +++ b/tools/router/appl/Router.cpp @@ -66,7 +66,7 @@ namespace appl { class TcpServerInput { private: enet::TcpServer m_interface; - std::thread* m_thread; + ethread::Thread* m_thread; bool m_threadRunning; appl::Router* m_router; bool m_service; @@ -84,7 +84,7 @@ namespace appl { m_interface.setPort(_port); m_interface.link(); m_threadRunning = true; - m_thread = new std::thread([&](void *){ this->threadCallback();}, nullptr); + m_thread = new ethread::Thread([&](void *){ this->threadCallback();}, nullptr); if (m_thread == nullptr) { m_threadRunning = false; ZEUS_ERROR("creating callback thread!"); diff --git a/tools/service-picture/appl/main-service-picture.cpp b/tools/service-picture/appl/main-service-picture.cpp index ba97c4a..a26a3e8 100644 --- a/tools/service-picture/appl/main-service-picture.cpp +++ b/tools/service-picture/appl/main-service-picture.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ #include #include -static std::mutex g_mutex; +static ethread::Mutex g_mutex; static etk::String g_basePath; static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; class FileProperty { @@ -78,13 +78,13 @@ namespace appl { } public: uint32_t mediaIdCount() override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... return m_listFile.size(); } etk::Vector mediaIdGetRange(uint32_t _start, uint32_t _stop) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... etk::Vector out; for (size_t iii=_start; iii mediaGet(uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... //Check if the file exist: bool find = false; @@ -112,7 +112,7 @@ namespace appl { return zeus::File::create(g_basePath + property.m_fileName + "." + zeus::getExtention(property.m_mineType), "", property.m_mineType); } uint32_t mediaAdd(zeus::ProxyFile _dataFile) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... uint64_t id = createUniqueID(); @@ -151,7 +151,7 @@ namespace appl { return id; } void mediaRemove(uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... //Check if the file exist: bool find = false; @@ -229,7 +229,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } uint32_t albumCreate(etk::String _albumName) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... for (auto &it : m_listAlbum) { if (it.m_name == _albumName) { @@ -245,7 +245,7 @@ namespace appl { void albumRemove(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... for (auto it = m_listAlbum.begin(); it != m_listAlbum.end(); @@ -259,7 +259,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } etk::Vector albumGetList() override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::Vector out; for (auto &it : m_listAlbum) { out.pushBack(it.m_id); @@ -267,7 +267,7 @@ namespace appl { return out; } etk::String albumNameGet(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { return it.m_name; @@ -277,7 +277,7 @@ namespace appl { return ""; } void albumNameSet(uint32_t _albumId, etk::String _albumName) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { it.m_name = _albumName; @@ -287,7 +287,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } etk::String albumDescriptionGet(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { return it.m_description; @@ -297,7 +297,7 @@ namespace appl { return ""; } void albumDescriptionSet(uint32_t _albumId, etk::String _desc) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { it.m_description = _desc; @@ -307,7 +307,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } void albumMediaAdd(uint32_t _albumId, uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { for (auto &elem : it.m_listMedia) { @@ -323,7 +323,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } void albumMediaRemove(uint32_t _albumId, uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { for (auto elem = it.m_listMedia.begin(); @@ -342,7 +342,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } uint32_t albumMediaCount(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { return it.m_listMedia.size(); @@ -352,7 +352,7 @@ namespace appl { return 0; } etk::Vector albumMediaIdGet(uint32_t _albumId, uint32_t _start, uint32_t _stop) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { etk::Vector out; @@ -368,7 +368,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } void albumParentSet(uint32_t _albumId, uint32_t _albumParentId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { it.m_parentId = _albumParentId; @@ -378,7 +378,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } void albumParentRemove(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { it.m_parentId = 0; @@ -388,7 +388,7 @@ namespace appl { throw std::invalid_argument("Wrong Album ID ..."); } uint32_t albumParentGet(uint32_t _albumId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listAlbum) { if (it.m_id == _albumId) { return it.m_parentId; @@ -493,7 +493,7 @@ static void load_db() { ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_WARNING("Load USER: " << g_basePath); load_db(); APPL_WARNING("new USER: [STOP]"); @@ -501,7 +501,7 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String } ETK_EXPORT_API bool SERVICE_IO_uninit() { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); store_db(); APPL_WARNING("delete USER [STOP]"); return true; diff --git a/tools/service-user/appl/main-service-user.cpp b/tools/service-user/appl/main-service-user.cpp index 92da11e..a13c811 100644 --- a/tools/service-user/appl/main-service-user.cpp +++ b/tools/service-user/appl/main-service-user.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -18,7 +18,7 @@ #include #include -static std::mutex g_mutex; +static ethread::Mutex g_mutex; static etk::String g_basePath; static etk::String g_baseDBName = etk::String(SERVICE_NAME) + "-database.json"; static ejson::Document g_database; @@ -54,7 +54,7 @@ namespace appl { // TODO: check if basished ... /* if (m_client.getName().get() != "") { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::Vector out; ejson::Object clients = g_database["client"].toObject(); if (clients.exist() == false) { @@ -83,7 +83,7 @@ namespace appl { return out; } bool checkTocken(etk::String _clientName, etk::String _tocken) { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_INFO("Check TOCKEN for : '" << _clientName << "' tocken='" << _clientName << "'"); ejson::Object clients = g_database["client"].toObject(); if (clients.exist() == false) { @@ -108,7 +108,7 @@ namespace appl { return false; } bool checkAuth(etk::String _password) { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_INFO("Check AUTH for : '" << _password << "'"); etk::String pass = g_database["password"].toString().get(); if (pass == "") { @@ -121,7 +121,7 @@ namespace appl { return false; } etk::Vector filterClientServices(etk::String _clientName, etk::Vector _currentList) { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_INFO("Filter services : '" << _clientName << "' " << _currentList); // When connected to our session ==> we have no control access ... if (_clientName == m_userName) { @@ -137,7 +137,7 @@ namespace appl { ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String _basePath) { g_basePath = _basePath; - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_WARNING("Load USER: " << g_basePath); bool ret = g_database.load(g_basePath + g_baseDBName); if (ret == false) { @@ -147,7 +147,7 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String } ETK_EXPORT_API bool SERVICE_IO_uninit() { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_DEBUG("Store User Info:"); bool ret = g_database.storeSafe(g_basePath + g_baseDBName); if (ret == false) { diff --git a/tools/service-video/appl/main-service-video.cpp b/tools/service-video/appl/main-service-video.cpp index 692c818..36c6e25 100644 --- a/tools/service-video/appl/main-service-video.cpp +++ b/tools/service-video/appl/main-service-video.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ #include #include -static std::mutex g_mutex; +static ethread::Mutex g_mutex; static etk::String g_basePath; static etk::String g_basePathCover; static etk::String g_basePathCoverGroup; @@ -130,13 +130,13 @@ namespace appl { } public: uint32_t count() override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... return m_listFile.size(); } etk::Vector getIds(uint32_t _start, uint32_t _stop) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... etk::Vector out; for (size_t iii=_start; iii lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... uint32_t out; for (size_t iii=0; iii get(uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... ememory::SharedPtr property; for (auto &it : m_listFile) { @@ -185,7 +185,7 @@ namespace appl { uint64_t id = 0; uint64_t importId = 0; { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... id = createUniqueID(); importId = createUniqueImportID(); @@ -197,7 +197,7 @@ namespace appl { futRemoteSha512.wait(); etk::String sha512StringRemote = futRemoteSha512.get(); { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { if (it == nullptr) { continue; @@ -221,7 +221,7 @@ namespace appl { throw std::runtime_error("file size == 0"); } if (zeus::getExtention(futType.get()) != "") { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::FSNodeMove(tmpFileName, g_basePath + sha512String + "." + zeus::getExtention(futType.get())); ememory::SharedPtr property = ememory::makeShared(id, sha512String + "." + zeus::getExtention(futType.get()), g_basePath); property->setMetadata("sha512", sha512String); @@ -230,7 +230,7 @@ namespace appl { m_listFile.pushBack(property); g_needToStore = true; } else { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::FSNodeMove(tmpFileName, g_basePath + sha512String); ememory::SharedPtr property = ememory::makeShared(id, sha512String, g_basePath); property->setMetadata("sha512", sha512String); @@ -242,7 +242,7 @@ namespace appl { return id; } void remove(uint32_t _mediaId) override { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); // TODO : Check right ... //Check if the file exist: bool find = false; @@ -354,7 +354,7 @@ namespace appl { } APPL_DEBUG("check : " << _sqlLikeRequest); etk::Vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { if (it == nullptr) { continue; @@ -375,7 +375,7 @@ namespace appl { throw std::invalid_argument("empty request"); } etk::Vector> listAndParsed = interpreteSQLRequest(_sqlLikeRequest); - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); for (auto &it : m_listFile) { if (it == nullptr) { continue; @@ -416,7 +416,7 @@ namespace appl { void internalSetCover(const etk::String& _baseName, zeus::ActionNotification& _notifs, zeus::ProxyFile _cover, etk::String _mediaString) { uint64_t importId = 0; { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); importId = createUniqueImportID(); } auto futType = _cover.getMineType(); @@ -432,11 +432,11 @@ namespace appl { throw std::runtime_error("file size > 1Mo"); } if (futType.get() == "image/png") { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::FSNodeRemove(_baseName + _mediaString + ".jpg"); etk::FSNodeMove(tmpFileName, _baseName + _mediaString + ".png"); } else if (futType.get() == "image/jpeg") { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); etk::FSNodeRemove(_baseName + _mediaString + ".png"); etk::FSNodeMove(tmpFileName, _baseName + _mediaString + ".jpg"); } else { @@ -510,7 +510,7 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String g_basePath = _basePath; g_basePathCover = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover/"; g_basePathCoverGroup = _basePath + "/AAAASDGDFGQN4352SCVdfgBSXDFGFCVQDSGFQSfd_cover_group/"; - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); APPL_WARNING("Load USER: " << g_basePath); load_db(); APPL_WARNING("new USER: [STOP]"); @@ -518,7 +518,7 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], etk::String } ETK_EXPORT_API bool SERVICE_IO_uninit() { - std::unique_lock lock(g_mutex); + std::unique_lock lock(g_mutex); store_db(); APPL_WARNING("delete USER [STOP]"); return true; diff --git a/zeus/Client.hpp b/zeus/Client.hpp index fbeab44..b2be4f9 100644 --- a/zeus/Client.hpp +++ b/zeus/Client.hpp @@ -97,7 +97,7 @@ namespace zeus { */ zeus::ObjectRemote getService(const etk::String& _serviceName); - using factoryService = std::function& _iface, uint32_t _destination)>; //!< call this function anser to the caller the requested Object + using factoryService = etk::Function& _iface, uint32_t _destination)>; //!< call this function anser to the caller the requested Object etk::Map m_listServicesAvaillable; //!< list of all factory availlable (to create new services) /** diff --git a/zeus/Future.hpp b/zeus/Future.hpp index d63cb27..4e29a61 100644 --- a/zeus/Future.hpp +++ b/zeus/Future.hpp @@ -91,7 +91,7 @@ namespace zeus { zeus::FutureBase::waitUntil(_endTime); return *this; } - using ObserverFut = std::function)>; //!< Define an Observer: function pointer for the local specific Future + using ObserverFut = etk::Function)>; //!< Define an Observer: function pointer for the local specific Future /** * @brief Attach callback on all return type of value * @param[in] _callback Handle on the function to call in all case @@ -108,7 +108,7 @@ namespace zeus { * @brief Attach callback on a specific return action (SUCESS) * @param[in] _callback Handle on the function to call in case of sucess on the call (return value) */ - Future& andThen(std::function _callback) { + Future& andThen(etk::Function _callback) { zeus::FutureBase::andThen( [=](zeus::FutureBase _fut) { zeus::Future tmp(_fut); @@ -121,7 +121,7 @@ namespace zeus { * @brief Attach callback on a specific return action (SUCESS) * @param[in] _callback Handle on the function to call in case of sucess on the call (return value) */ - Future& andThen(std::function _callback) { + Future& andThen(etk::Function _callback) { zeus::FutureBase::andThen( [=](zeus::FutureBase _fut) { return _callback(etk::move(zeus::Future(_fut).get())); @@ -145,7 +145,7 @@ namespace zeus { * @brief Attach callback on a specific return action (ERROR) * @param[in] _callback Handle on the function to call in case of error on the call (with error parameter (ERROR type, Help string) */ - Future& andElse(std::function _callback) { + Future& andElse(etk::Function _callback) { zeus::FutureBase::andElse( [=](zeus::FutureBase _fut) { return _callback(_fut.getErrorType(), _fut.getErrorHelp()); @@ -170,8 +170,8 @@ namespace zeus { * @brief Attach callback on activity of the action / signal * @param[in] _callback Handle on the function to call in progress information */ - //template::value, false>> - Future& onSignal(std::function _callback) { + //template::value, false>> + Future& onSignal(etk::Function _callback) { zeus::FutureBase::onEvent( [=](ememory::SharedPtr _msg) { if (_msg == nullptr) { @@ -186,8 +186,8 @@ namespace zeus { * @brief Attach callback on activity of the action / signal * @param[in] _callback Handle on the function to call in progress information */ - //template::value, false>> - Future& onSignal(std::function _callback) { + //template::value, false>> + Future& onSignal(etk::Function _callback) { zeus::FutureBase::onEvent( [=](ememory::SharedPtr _msg) { if (_msg == nullptr) { @@ -270,7 +270,7 @@ namespace zeus { zeus::FutureBase::waitUntil(_endTime); return *this; } - using ObserverFut = std::function)>; //!< Define an Observer: function pointer for the local specific Future + using ObserverFut = etk::Function)>; //!< Define an Observer: function pointer for the local specific Future /** * @brief Attach callback on all return type of value * @param[in] _callback Handle on the function to call in all case @@ -299,7 +299,7 @@ namespace zeus { * @brief Attach callback on a specific return action (SUCESS) * @param[in] _callback Handle on the function to call in case of sucess on the call (void parameter) */ - Future& andThen(std::function _callback) { + Future& andThen(etk::Function _callback) { zeus::FutureBase::andThen( [=](zeus::FutureBase _fut) { return _callback(); @@ -323,7 +323,7 @@ namespace zeus { * @brief Attach callback on a specific return action (ERROR) * @param[in] _callback Handle on the function to call in case of error on the call (with error parameter (ERROR type, Help string) */ - Future& andElse(std::function _callback) { + Future& andElse(etk::Function _callback) { zeus::FutureBase::andElse( [=](zeus::FutureBase _fut) { return _callback(_fut.getErrorType(), _fut.getErrorHelp()); @@ -335,8 +335,8 @@ namespace zeus { * @brief Attach callback on activity of the action / signal * @param[in] _callback Handle on the function to call in progress information */ - //template::value, false>> - Future& onSignal(std::function _callback) { + //template::value, false>> + Future& onSignal(etk::Function _callback) { zeus::FutureBase::onEvent( [=](ememory::SharedPtr _msg) { if (_msg == nullptr) { @@ -351,8 +351,8 @@ namespace zeus { * @brief Attach callback on activity of the action / signal * @param[in] _callback Handle on the function to call in progress information */ - //template::value, false>> - Future& onSignal(std::function _callback) { + //template::value, false>> + Future& onSignal(etk::Function _callback) { zeus::FutureBase::onEvent( [=](ememory::SharedPtr _msg) { if (_msg == nullptr) { diff --git a/zeus/Promise.cpp b/zeus/Promise.cpp index 008920c..c4cb77d 100644 --- a/zeus/Promise.cpp +++ b/zeus/Promise.cpp @@ -50,7 +50,7 @@ void zeus::Promise::setAction() { void zeus::Promise::andAll(zeus::Promise::Observer _callback) { { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackThen = _callback; m_callbackElse = _callback; } @@ -58,12 +58,12 @@ void zeus::Promise::andAll(zeus::Promise::Observer _callback) { return; } if (hasError() == false) { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_callbackThen != nullptr) { m_callbackThen(zeus::FutureBase(sharedFromThis())); } } else { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_callbackElse != nullptr) { m_callbackElse(zeus::FutureBase(sharedFromThis())); } @@ -72,7 +72,7 @@ void zeus::Promise::andAll(zeus::Promise::Observer _callback) { void zeus::Promise::andThen(zeus::Promise::Observer _callback) { { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackThen = _callback; } if (isFinished() == false) { @@ -81,7 +81,7 @@ void zeus::Promise::andThen(zeus::Promise::Observer _callback) { if (hasError() == true) { return; } - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_callbackThen == nullptr) { return; } @@ -90,7 +90,7 @@ void zeus::Promise::andThen(zeus::Promise::Observer _callback) { void zeus::Promise::andElse(zeus::Promise::Observer _callback) { { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackElse = _callback; } if (isFinished() == false) { @@ -99,7 +99,7 @@ void zeus::Promise::andElse(zeus::Promise::Observer _callback) { if (hasError() == false) { return; } - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_callbackElse == nullptr) { return; } @@ -107,7 +107,7 @@ void zeus::Promise::andElse(zeus::Promise::Observer _callback) { } void zeus::Promise::onEvent(zeus::Promise::ObserverEvent _callback) { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_isAction == false) { ZEUS_ERROR("Request a Event calback on a simple function call"); } @@ -118,22 +118,22 @@ echrono::Duration zeus::Promise::getTransmitionTime() const { if (isFinished() == false) { return echrono::nanoseconds(0); } - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_receiveTime - m_sendTime; } bool zeus::Promise::setMessage(ememory::SharedPtr _value) { { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_receiveTime = echrono::Steady::now(); } if (_value->getType() == zeus::message::type::event) { ObserverEvent callback; { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); callback = m_callbackEvent; } - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); // notification of a progresion ... if (callback != nullptr) { if (_value == nullptr) { @@ -141,7 +141,7 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { } callback(ememory::staticPointerCast(_value)); { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackEvent = etk::move(callback); } return false; // no error @@ -149,7 +149,7 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { return false; } { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_message = _value; if (m_message == nullptr) { return true; @@ -162,13 +162,13 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { if (hasError() == false) { Observer callback; { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); callback = etk::move(m_callbackThen); } if (callback != nullptr) { bool ret = callback(zeus::FutureBase(sharedFromThis())); { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackThen = etk::move(callback); } return ret; @@ -176,13 +176,13 @@ bool zeus::Promise::setMessage(ememory::SharedPtr _value) { } else { Observer callback; { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); callback = m_callbackElse; } if (callback != nullptr) { bool ret = callback(zeus::FutureBase(sharedFromThis())); { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_callbackElse = etk::move(callback); } return ret; @@ -200,7 +200,7 @@ uint32_t zeus::Promise::getSource() const { } bool zeus::Promise::hasError() const { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_message == nullptr) { return true; } @@ -211,7 +211,7 @@ bool zeus::Promise::hasError() const { } etk::String zeus::Promise::getErrorType() const { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_message == nullptr) { return "NULL_PTR"; } @@ -222,7 +222,7 @@ etk::String zeus::Promise::getErrorType() const { } etk::String zeus::Promise::getErrorHelp() const { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_message == nullptr) { return "This is a nullptr future"; } @@ -234,7 +234,7 @@ etk::String zeus::Promise::getErrorHelp() const { bool zeus::Promise::isFinished() const { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if (m_message == nullptr) { // in this case, we are waiting for an answer that the first packet is not arrived return false; diff --git a/zeus/Promise.hpp b/zeus/Promise.hpp index 9bf7488..05e8c9a 100644 --- a/zeus/Promise.hpp +++ b/zeus/Promise.hpp @@ -21,10 +21,10 @@ namespace zeus { */ class Promise : public ememory::EnableSharedFromThis { public: - using Observer = std::function; //!< Define an Observer: function pointer - using ObserverEvent = std::function)>; //!< Define the observer on activity of the action (note that is a string, but it can contain json or other ...) + using Observer = etk::Function; //!< Define an Observer: function pointer + using ObserverEvent = etk::Function)>; //!< Define the observer on activity of the action (note that is a string, but it can contain json or other ...) private: - mutable std::mutex m_mutex; //!< local prevention of multiple acess + mutable ethread::Mutex m_mutex; //!< local prevention of multiple acess uint32_t m_transactionId; //!< waiting answer data uint32_t m_source; //!< Source of the message. ememory::SharedPtr m_message; //!< all buffer concatenate or last buffer if synchronous diff --git a/zeus/WebServer.cpp b/zeus/WebServer.cpp index 7c6517f..3d2e01d 100644 --- a/zeus/WebServer.cpp +++ b/zeus/WebServer.cpp @@ -109,12 +109,12 @@ void zeus::WebServer::setInterfaceName(const etk::String& _name) { } void zeus::WebServer::addWebObj(ememory::SharedPtr _obj) { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); m_listObject.pushBack(_obj); } void zeus::WebServer::addWebObjRemote(ememory::SharedPtr _obj) { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); m_listRemoteObject.pushBack(_obj); } @@ -152,7 +152,7 @@ void zeus::WebServer::interfaceRemoved(etk::Vector _list) { } } for (int32_t iii=0; iii < _list.size(); ++iii) { - std::unique_lock lock(m_pendingCallMutex); + std::unique_lock lock(m_pendingCallMutex); auto it = m_pendingCall.begin(); while (it != m_pendingCall.end()) { if (it->second.isValid() == false) { @@ -177,7 +177,7 @@ bool zeus::WebServer::isActive() const { void zeus::WebServer::connect(bool _async){ ZEUS_DEBUG("connect [START]"); m_threadAsyncRunning = true; - m_threadAsync = new std::thread([&](void *){ this->threadAsyncCallback();}, nullptr); + m_threadAsync = new ethread::Thread([&](void *){ this->threadAsyncCallback();}, nullptr); if (m_threadAsync == nullptr) { m_threadAsyncRunning = false; ZEUS_ERROR("creating async sender thread!"); @@ -350,13 +350,13 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { } if ( _buffer->getPartFinish() == false && _buffer->getType() != zeus::message::type::data) { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); m_listPartialMessage.pushBack(_buffer); return; } if (_buffer->getType() == zeus::message::type::data) { // Add data in a previous buffer... - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); auto it = m_listPartialMessage.begin(); while (it != m_listPartialMessage.end()) { if (*it == nullptr) { @@ -391,7 +391,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { if ( _buffer->getType() == zeus::message::type::answer || _buffer->getType() == zeus::message::type::data || _buffer->getType() == zeus::message::type::event) { - std::unique_lock lock(m_pendingCallMutex); + std::unique_lock lock(m_pendingCallMutex); auto it = m_pendingCall.begin(); while (it != m_pendingCall.end()) { if (it->second.isValid() == false) { @@ -429,7 +429,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { return; } } - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); // call local map object on remote object for (auto &it : m_listRemoteObject) { ememory::SharedPtr tmp = it.lock(); @@ -468,7 +468,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { bool ret = fut.setMessage(_buffer); if (ret == true) { ZEUS_LOG_INPUT_OUTPUT(" ==> start LOCK"); - std::unique_lock lock(m_pendingCallMutex); + std::unique_lock lock(m_pendingCallMutex); ZEUS_LOG_INPUT_OUTPUT(" ==> LOCK done"); auto it = m_pendingCall.begin(); while (it != m_pendingCall.end()) { @@ -493,7 +493,7 @@ void zeus::WebServer::newMessage(ememory::SharedPtr _buffer) { } void zeus::WebServer::listObjects() { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); if ( m_listObject.size() == 0 && m_listRemoteObject.size() == 0) { return; @@ -515,7 +515,7 @@ void zeus::WebServer::listObjects() { } void zeus::WebServer::cleanDeadObject() { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); if ( m_listObject.size() == 0 && m_listRemoteObject.size() == 0) { return; @@ -545,7 +545,7 @@ void zeus::WebServer::cleanDeadObject() { } bool zeus::WebServer::transferRemoteObjectOwnership(uint16_t _objectAddress, uint32_t _sourceAddress, uint32_t _destinataireAddress) { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); if ( m_listObject.size() == 0 && m_listRemoteObject.size() == 0) { return false; @@ -572,7 +572,7 @@ bool zeus::WebServer::transferRemoteObjectOwnership(uint16_t _objectAddress, uin } bool zeus::WebServer::removeObjectOwnership(uint16_t _objectAddress, uint32_t _sourceAddress) { - //std::unique_lock lock(m_mutex); + //std::unique_lock lock(m_mutex); if ( m_listObject.size() == 0 && m_listRemoteObject.size() == 0) { return false; @@ -601,7 +601,7 @@ bool zeus::WebServer::removeObjectOwnership(uint16_t _objectAddress, uint32_t _s } void zeus::WebServer::addAsync(zeus::WebServer::ActionAsync _elem) { - std::unique_lock lock(m_threadAsyncMutex); + std::unique_lock lock(m_threadAsyncMutex); m_threadAsyncList2.pushBack(_elem); ZEUS_DEBUG("ADD element to send ... " << m_threadAsyncList2.size()); } @@ -613,7 +613,7 @@ void zeus::WebServer::threadAsyncCallback() { while ( m_threadAsyncRunning == true && m_connection.isAlive() == true) { if (m_threadAsyncList2.size() != 0) { - std::unique_lock lock(m_threadAsyncMutex); + std::unique_lock lock(m_threadAsyncMutex); for (auto &it : m_threadAsyncList2) { m_threadAsyncList.pushBack(it); } @@ -649,7 +649,7 @@ zeus::FutureBase zeus::WebServer::callBinary(ememory::SharedPtr _ } zeus::FutureBase tmpFuture(_obj->getTransactionId()); { - std::unique_lock lock(m_pendingCallMutex); + std::unique_lock lock(m_pendingCallMutex); m_pendingCall.pushBack(etk::makePair(uint64_t(0), tmpFuture)); } writeBinary(_obj); diff --git a/zeus/WebServer.hpp b/zeus/WebServer.hpp index 96f2897..c7c7975 100644 --- a/zeus/WebServer.hpp +++ b/zeus/WebServer.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,7 +109,7 @@ namespace zeus { */ class WebServer : public ememory::EnableSharedFromThis { protected: - std::mutex m_mutex; //!< main interface lock + ethread::Mutex m_mutex; //!< main interface lock public: etk::Vector> m_actifObject; //!< List of all active object created and that remove is in progress ... private: @@ -138,7 +138,7 @@ namespace zeus { * @return a new single object ID */ uint16_t getNewObjectId() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); return m_localIdObjectIncrement++; } private: @@ -171,10 +171,10 @@ namespace zeus { * @return Unique ID of the transmision */ uint16_t getId(); - std::mutex m_pendingCallMutex; //!< local call of a pendinc call venctor update + ethread::Mutex m_pendingCallMutex; //!< local call of a pendinc call venctor update etk::Vector> m_pendingCall; //!< List of pending call interface public: - using Observer = std::function)>; //!< Define an Observer: function pointer + using Observer = etk::Function)>; //!< Define an Observer: function pointer Observer m_observerElement; //!< Observer on a new message arriving /** * @brief Connect an function member on the signal with the shared_ptr object. @@ -188,7 +188,7 @@ namespace zeus { }; } public: - using ObserverRequestUri = std::function; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not) + using ObserverRequestUri = etk::Function; //!< Define an Observer on the specific URI requested callback: function pointer (return true if the connection is accepted or not) protected: ObserverRequestUri m_observerRequestUri; //!< Observer on a requesting URI connection public: @@ -299,9 +299,9 @@ namespace zeus { return m_connection.getLastTimeSend(); } private: - using ActionAsync = std::function; //!< type of the action for sending big data on the websocket - std::mutex m_threadAsyncMutex; //!< Mutex fot the thread to send async data - std::thread* m_threadAsync; //!< sending async data thread. TODO: Set it in a thread pool ... + using ActionAsync = etk::Function; //!< type of the action for sending big data on the websocket + ethread::Mutex m_threadAsyncMutex; //!< Mutex fot the thread to send async data + ethread::Thread* m_threadAsync; //!< sending async data thread. TODO: Set it in a thread pool ... bool m_threadAsyncRunning; //!< Threa is running etk::Vector m_threadAsyncList; //!< List of action to send (current) etk::Vector m_threadAsyncList2; //!< list of action to send whenwurrent is sending in progress diff --git a/zeus/message/Answer.cpp b/zeus/message/Answer.cpp index 5abe02e..ea63b6a 100644 --- a/zeus/message/Answer.cpp +++ b/zeus/message/Answer.cpp @@ -40,7 +40,7 @@ void zeus::message::Answer::addError(const etk::String& _value, const etk::Strin } bool zeus::message::Answer::writeOn(enet::WebSocket& _interface) { - std::unique_lock lock = _interface.getScopeLock(); + std::unique_lock lock = _interface.getScopeLock(); zeus::Message::writeOn(_interface); _interface.writeData((uint8_t*)m_errorType.c_str(), m_errorType.size() + 1); if (m_errorType.size() != 0) { diff --git a/zeus/message/Call.cpp b/zeus/message/Call.cpp index 3296880..aebaa1f 100644 --- a/zeus/message/Call.cpp +++ b/zeus/message/Call.cpp @@ -35,7 +35,7 @@ void zeus::message::Call::setCall(const etk::String& _value) { } bool zeus::message::Call::writeOn(enet::WebSocket& _interface) { - std::unique_lock lock = _interface.getScopeLock(); + std::unique_lock lock = _interface.getScopeLock(); zeus::Message::writeOn(_interface); _interface.writeData((uint8_t*)m_callName.c_str(), m_callName.size() + 1); if (message::Parameter::writeOn(_interface) == false) { diff --git a/zeus/message/Data.cpp b/zeus/message/Data.cpp index bb47f25..4184ca0 100644 --- a/zeus/message/Data.cpp +++ b/zeus/message/Data.cpp @@ -37,7 +37,7 @@ void zeus::message::Data::setPartId(uint32_t _value) { } bool zeus::message::Data::writeOn(enet::WebSocket& _interface) { - std::unique_lock lock = _interface.getScopeLock(); + std::unique_lock lock = _interface.getScopeLock(); if (zeus::Message::writeOn(_interface) == false) { return false; } diff --git a/zeus/message/Event.cpp b/zeus/message/Event.cpp index 4a8a33f..163009d 100644 --- a/zeus/message/Event.cpp +++ b/zeus/message/Event.cpp @@ -18,7 +18,7 @@ void zeus::message::Event::generateDisplay(etk::Stream& _os) const { } bool zeus::message::Event::writeOn(enet::WebSocket& _interface) { - std::unique_lock lock = _interface.getScopeLock(); + std::unique_lock lock = _interface.getScopeLock(); zeus::Message::writeOn(_interface); _interface.writeData((uint8_t*)(&m_uid), sizeof(m_uid)); if (message::Parameter::writeOn(_interface) == false) { diff --git a/zeus/message/Message.hpp b/zeus/message/Message.hpp index 60f8034..b89210b 100644 --- a/zeus/message/Message.hpp +++ b/zeus/message/Message.hpp @@ -12,7 +12,7 @@ namespace zeus { class WebServer; // define basic async call element ... - using ActionAsyncClient = std::function; + using ActionAsyncClient = etk::Function; } diff --git a/zeus/zeus-Media.impl.hpp b/zeus/zeus-Media.impl.hpp index c8d138f..19b1a18 100644 --- a/zeus/zeus-Media.impl.hpp +++ b/zeus/zeus-Media.impl.hpp @@ -17,9 +17,9 @@ namespace zeus { etk::String m_basePath; //!< basic global path etk::String m_fileName; //!< Name of the file etk::Map m_metadata; //!< all extra property - std::function m_callback; + etk::Function m_callback; public: - void setCallbackMetadataChange(std::function _callback) { + void setCallbackMetadataChange(etk::Function _callback) { m_callback = _callback; } public: