diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2ae5672..2e89d86b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,8 +64,6 @@ add_library(oatpp oatpp/core/base/memory/ObjectPool.cpp oatpp/core/base/memory/ObjectPool.hpp oatpp/core/collection/FastQueue.hpp - oatpp/core/collection/LinkedList.hpp - oatpp/core/concurrency/SpinLock.cpp oatpp/core/concurrency/SpinLock.hpp oatpp/core/concurrency/Thread.cpp diff --git a/src/oatpp/core/async/Executor.hpp b/src/oatpp/core/async/Executor.hpp index 1b52795a..77c7c14b 100644 --- a/src/oatpp/core/async/Executor.hpp +++ b/src/oatpp/core/async/Executor.hpp @@ -31,8 +31,6 @@ #include "oatpp/core/concurrency/SpinLock.hpp" #include "oatpp/core/concurrency/Thread.hpp" -#include "oatpp/core/collection/LinkedList.hpp" - #include #include #include diff --git a/src/oatpp/core/async/worker/IOWorker.hpp b/src/oatpp/core/async/worker/IOWorker.hpp index 57ae904c..d3a72a2a 100644 --- a/src/oatpp/core/async/worker/IOWorker.hpp +++ b/src/oatpp/core/async/worker/IOWorker.hpp @@ -26,7 +26,6 @@ #define oatpp_async_worker_IOWorker_hpp #include "./Worker.hpp" -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/concurrency/SpinLock.hpp" #include diff --git a/src/oatpp/core/async/worker/TimerWorker.hpp b/src/oatpp/core/async/worker/TimerWorker.hpp index 1413cb38..1c42a6d3 100644 --- a/src/oatpp/core/async/worker/TimerWorker.hpp +++ b/src/oatpp/core/async/worker/TimerWorker.hpp @@ -26,7 +26,6 @@ #define oatpp_async_worker_TimerWorker_hpp #include "./Worker.hpp" -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/concurrency/SpinLock.hpp" #include diff --git a/src/oatpp/core/collection/LinkedList.hpp b/src/oatpp/core/collection/LinkedList.hpp deleted file mode 100644 index 86df4c87..00000000 --- a/src/oatpp/core/collection/LinkedList.hpp +++ /dev/null @@ -1,281 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************/ - -#ifndef oatpp_collection_LinkedList_hpp -#define oatpp_collection_LinkedList_hpp - -#include "oatpp/core/base/memory/ObjectPool.hpp" - - -#include "oatpp/core/base/Countable.hpp" -#include "oatpp/core/base/Environment.hpp" - -namespace oatpp { namespace collection { - -template -class LinkedList : public base::Countable { -public: - OBJECT_POOL(LinkedList_Pool, LinkedList, 32) - SHARED_OBJECT_POOL(Shared_LinkedList_Pool, LinkedList, 32) -public: - - class LinkedListNode { - friend LinkedList; - friend oatpp::base::memory::MemoryPool; - public: - OBJECT_POOL_THREAD_LOCAL(LinkedList_Node_Pool, LinkedListNode, 32) - private: - T data; - LinkedListNode* next; - - protected: - - LinkedListNode(const T& nodeData, LinkedListNode* nextNode) - : data(nodeData) - , next(nextNode) - {} - - ~LinkedListNode(){ - } - - public: - - const T& getData(){ - return data; - } - - LinkedListNode* getNext(){ - return next; - } - - }; - -private: - LinkedListNode* m_first; - LinkedListNode* m_last; - v_int32 m_count; - oatpp::base::memory::MemoryPool& m_itemMemoryPool; - - LinkedListNode* createNode(const T& data, LinkedListNode* next){ - return new (m_itemMemoryPool.obtain()) LinkedListNode(data, next); - } - - void destroyNode(LinkedListNode* node){ - node->~LinkedListNode(); - oatpp::base::memory::MemoryPool::free(node); - } - -public: - - LinkedList() - : m_first(nullptr) - , m_last(nullptr) - , m_count(0) - , m_itemMemoryPool(LinkedListNode::LinkedList_Node_Pool::getPool()) - {} - -public: - - static std::shared_ptr createShared(){ - return Shared_LinkedList_Pool::allocateShared(); - } - - static std::shared_ptr copy(LinkedList* other){ - auto result = createShared(); - auto curr = other->m_first; - while(curr != nullptr){ - result->pushBack(curr->data); - curr = curr->next; - } - return result; - } - - virtual ~LinkedList() { - clear(); - } - - void pushFront(const T& data){ - - if(m_first == nullptr){ - LinkedListNode* newNode = createNode(data, nullptr); - m_first = newNode; - m_last = newNode; - }else{ - LinkedListNode* newNode = createNode(data, m_first); - m_first = newNode; - } - m_count++; - - } - - void pushBack(const T& data){ - - LinkedListNode* newNode = createNode(data, nullptr); - - if(m_last == nullptr){ - m_first = newNode; - m_last = newNode; - }else{ - m_last->next = newNode; - m_last = newNode; - } - - m_count++; - - } - - void pushBackAll(const std::shared_ptr& list){ - auto curr = list->getFirstNode(); - while(curr != nullptr) { - pushBack(curr->getData()); - curr = curr->getNext(); - } - } - - void insertAfterNode(const T& data, LinkedListNode* currentNode){ - LinkedListNode* node = createNode(data, currentNode->next); - currentNode->next = node; - if(currentNode == m_last){ - m_last = node; - } - m_count++; - } - - T popFront(){ - if(m_first != nullptr){ - LinkedListNode* node = m_first; - m_first = m_first->next; - if(m_first == nullptr){ - m_last = nullptr; - } - m_count --; - T result = node->data; - destroyNode(node); - return result; - } - throw std::runtime_error("[oatpp::collection::LinkedList::popFront()]: index out of bounds"); - } - - const T& getFirst() const{ - return m_first->data; - } - - const T& getLast() const{ - return m_last->data; - } - - const T& get(v_int32 index) const{ - - LinkedListNode* node = getNode(index); - if(node != nullptr){ - return node->data; - } - - throw std::runtime_error("[oatpp::collection::LinkedList::get(index)]: index out of bounds"); - - } - - LinkedListNode* getNode(v_int32 index) const { - - if(index >= m_count){ - return nullptr; - } - - v_int32 i = 0; - LinkedListNode* curr = m_first; - - while(curr != nullptr){ - - if(i == index){ - return curr; - } - - curr = curr->next; - i++; - } - - return nullptr; - - } - - LinkedListNode* getFirstNode() const { - return m_first; - } - - v_int32 count() const{ - return m_count; - } - - /** - * for each item call a function - * - * list->forEachNode([](auto item){ - * // your code here - * }); - */ - template - void forEach(const F& lambda) const { - auto curr = m_first; - while(curr != nullptr) { - lambda(curr->data); - curr = curr->next; - } - } - - /** - * for each node call a function - * - * list->forEachNode([](auto node){ - * // your code here - * }); - */ - template - void forEachNode(const F& lambda) const { - auto curr = m_first; - while(curr != nullptr) { - lambda(curr); - curr = curr->next; - } - } - - void clear(){ - - LinkedListNode* curr = m_first; - while(curr != nullptr){ - LinkedListNode* next = curr->next; - destroyNode(curr); - curr = next; - } - - m_first = nullptr; - m_last = nullptr; - m_count = 0; - - } - -}; - -}} - -#endif /* oatpp_collection_LinkedList_hpp */ diff --git a/src/oatpp/core/data/mapping/type/Any.hpp b/src/oatpp/core/data/mapping/type/Any.hpp index 3441d10f..46c90b1d 100644 --- a/src/oatpp/core/data/mapping/type/Any.hpp +++ b/src/oatpp/core/data/mapping/type/Any.hpp @@ -27,8 +27,6 @@ #include "./Type.hpp" -#include "oatpp/core/collection/LinkedList.hpp" - #include "oatpp/core/base/memory/ObjectPool.hpp" #include "oatpp/core/base/Countable.hpp" diff --git a/src/oatpp/core/data/stream/ChunkedBuffer.cpp b/src/oatpp/core/data/stream/ChunkedBuffer.cpp index 359bb6c4..3822e947 100644 --- a/src/oatpp/core/data/stream/ChunkedBuffer.cpp +++ b/src/oatpp/core/data/stream/ChunkedBuffer.cpp @@ -303,15 +303,13 @@ oatpp::async::CoroutineStarter ChunkedBuffer::flushToStreamAsync(const std::shar } std::shared_ptr ChunkedBuffer::getChunks() { - auto chunks = Chunks::createShared(); + auto chunks = std::make_shared(); auto curr = m_firstEntry; v_int32 count = 0; while (curr != nullptr) { - if(curr->next != nullptr){ - chunks->pushBack(Chunk::createShared(curr->chunk, CHUNK_ENTRY_SIZE)); - } else { - chunks->pushBack(Chunk::createShared(curr->chunk, m_size - CHUNK_ENTRY_SIZE * count)); - } + chunks->push_back(Chunk::createShared(curr->chunk, curr->next + ? CHUNK_ENTRY_SIZE + : m_size - CHUNK_ENTRY_SIZE * count)); ++count; curr = curr->next; } diff --git a/src/oatpp/core/data/stream/ChunkedBuffer.hpp b/src/oatpp/core/data/stream/ChunkedBuffer.hpp index c51c0ebb..50effa5c 100644 --- a/src/oatpp/core/data/stream/ChunkedBuffer.hpp +++ b/src/oatpp/core/data/stream/ChunkedBuffer.hpp @@ -25,9 +25,10 @@ #ifndef oatpp_data_stream_ChunkedBuffer_hpp #define oatpp_data_stream_ChunkedBuffer_hpp +#include + #include "Stream.hpp" -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/async/Coroutine.hpp" namespace oatpp { namespace data{ namespace stream { @@ -99,7 +100,7 @@ public: }; public: - typedef oatpp::collection::LinkedList> Chunks; + typedef std::list> Chunks; private: v_buff_size m_size; diff --git a/src/oatpp/core/parser/Caret.hpp b/src/oatpp/core/parser/Caret.hpp index 74a36d34..cf0489a9 100644 --- a/src/oatpp/core/parser/Caret.hpp +++ b/src/oatpp/core/parser/Caret.hpp @@ -25,7 +25,6 @@ #ifndef oatpp_parser_Caret_hpp #define oatpp_parser_Caret_hpp -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/Types.hpp" namespace oatpp { namespace parser { diff --git a/src/oatpp/network/virtual_/Interface.cpp b/src/oatpp/network/virtual_/Interface.cpp index 1c3b385c..962b7b4e 100644 --- a/src/oatpp/network/virtual_/Interface.cpp +++ b/src/oatpp/network/virtual_/Interface.cpp @@ -184,7 +184,7 @@ std::shared_ptr Interface::connect() { auto submission = std::make_shared(true); { std::lock_guard lock(m_mutex); - m_submissions.pushBack(submission); + m_submissions.push_back(submission); } m_condition.notify_one(); return submission; @@ -199,7 +199,7 @@ std::shared_ptr Interface::connectNonBlocking() std::unique_lock lock(m_mutex, std::try_to_lock); if (lock.owns_lock()) { submission = std::make_shared(true); - m_submissions.pushBack(submission); + m_submissions.push_back(submission); } } if (submission) { @@ -212,19 +212,23 @@ std::shared_ptr Interface::connectNonBlocking() std::shared_ptr Interface::accept(const bool& waitingHandle) { std::unique_lock lock(m_mutex); - while (waitingHandle && m_submissions.getFirstNode() == nullptr) { + while (waitingHandle && m_submissions.empty()) { m_condition.wait(lock); } if(!waitingHandle) { return nullptr; } - return acceptSubmission(m_submissions.popFront()); + const auto submission = m_submissions.front(); + m_submissions.pop_front(); + return acceptSubmission(submission); } std::shared_ptr Interface::acceptNonBlocking() { std::unique_lock lock(m_mutex, std::try_to_lock); - if(lock.owns_lock() && m_submissions.getFirstNode() != nullptr) { - return acceptSubmission(m_submissions.popFront()); + if(lock.owns_lock() && !m_submissions.empty()) { + const auto submission = m_submissions.front(); + m_submissions.pop_front(); + return acceptSubmission(submission); } return nullptr; } @@ -233,14 +237,9 @@ void Interface::dropAllConnection() { std::unique_lock lock(m_mutex); - auto curr = m_submissions.getFirstNode(); - - while(curr != nullptr) { - auto submission = curr->getData(); + for (const auto& submission : m_submissions) { submission->invalidate(); - curr = curr->getNext(); } - m_submissions.clear(); } diff --git a/src/oatpp/network/virtual_/Interface.hpp b/src/oatpp/network/virtual_/Interface.hpp index 179107d7..bf6857a6 100644 --- a/src/oatpp/network/virtual_/Interface.hpp +++ b/src/oatpp/network/virtual_/Interface.hpp @@ -27,8 +27,7 @@ #include "./Socket.hpp" -#include "oatpp/core/collection/LinkedList.hpp" - +#include #include namespace oatpp { namespace network { namespace virtual_ { @@ -116,7 +115,7 @@ private: std::mutex m_listenerMutex; std::mutex m_mutex; std::condition_variable m_condition; - oatpp::collection::LinkedList> m_submissions; + std::list> m_submissions; private: Interface(const oatpp::String& name); diff --git a/src/oatpp/web/server/api/ApiController.cpp b/src/oatpp/web/server/api/ApiController.cpp index 66d020be..d5a09f49 100644 --- a/src/oatpp/web/server/api/ApiController.cpp +++ b/src/oatpp/web/server/api/ApiController.cpp @@ -28,12 +28,9 @@ namespace oatpp { namespace web { namespace server { namespace api { void ApiController::addEndpointsToRouter(const std::shared_ptr& router){ - auto node = m_endpoints->getFirstNode(); - while (node != nullptr) { - auto endpoint = node->getData(); + for (const auto& endpoint : *m_endpoints) { router->route(endpoint->info()->method, endpoint->info()->path, endpoint->handler); - node = node->getNext(); - } + }; } std::shared_ptr ApiController::getEndpoints() { diff --git a/src/oatpp/web/server/api/ApiController.hpp b/src/oatpp/web/server/api/ApiController.hpp index 6e97707c..c6aaff58 100644 --- a/src/oatpp/web/server/api/ApiController.hpp +++ b/src/oatpp/web/server/api/ApiController.hpp @@ -36,9 +36,9 @@ #include "oatpp/web/protocol/http/outgoing/Request.hpp" #include "oatpp/web/protocol/http/outgoing/ResponseFactory.hpp" -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/utils/ConversionUtils.hpp" +#include #include namespace oatpp { namespace web { namespace server { namespace api { @@ -104,7 +104,7 @@ public: /** * Convenience typedef for list of &id:oatpp::web::server::api::Endpoint;. */ - typedef oatpp::collection::LinkedList> Endpoints; + typedef std::list> Endpoints; /** * Convenience typedef for &id:oatpp::web::server::HttpRequestHandler;. @@ -369,7 +369,7 @@ protected: std::shared_ptr getEndpointHandler(const std::string& endpointName); protected: - std::shared_ptr m_endpoints; + std::shared_ptr m_endpoints{std::make_shared()}; std::shared_ptr m_errorHandler; std::shared_ptr m_defaultAuthorizationHandler; std::shared_ptr m_defaultObjectMapper; @@ -378,9 +378,7 @@ protected: const oatpp::String m_routerPrefix; public: ApiController(const std::shared_ptr& defaultObjectMapper, const oatpp::String &routerPrefix = nullptr) - : m_endpoints(Endpoints::createShared()) - , m_errorHandler(nullptr) - , m_defaultObjectMapper(defaultObjectMapper) + : m_defaultObjectMapper(defaultObjectMapper) , m_routerPrefix(routerPrefix) {} public: @@ -391,7 +389,7 @@ public: const EndpointInfoBuilder& infoBuilder) { auto endpoint = Endpoint::createShared(handler, infoBuilder); - endpoints->pushBack(endpoint); + endpoints->push_back(endpoint); return endpoint; } diff --git a/src/oatpp/web/url/mapping/Pattern.cpp b/src/oatpp/web/url/mapping/Pattern.cpp index f0653b75..c123222a 100644 --- a/src/oatpp/web/url/mapping/Pattern.cpp +++ b/src/oatpp/web/url/mapping/Pattern.cpp @@ -51,7 +51,7 @@ std::shared_ptr Pattern::parse(p_char8 data, v_buff_size size){ if(i - lastPos > 0){ auto part = Part::createShared(Part::FUNCTION_CONST, oatpp::String((const char*)&data[lastPos], i - lastPos, true)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); } lastPos = i + 1; @@ -60,10 +60,10 @@ std::shared_ptr Pattern::parse(p_char8 data, v_buff_size size){ lastPos = i + 1; if(size > lastPos){ auto part = Part::createShared(Part::FUNCTION_ANY_END, oatpp::String((const char*)&data[lastPos], size - lastPos, true)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); }else{ auto part = Part::createShared(Part::FUNCTION_ANY_END, oatpp::String((v_buff_size)0)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); } return result; @@ -76,10 +76,10 @@ std::shared_ptr Pattern::parse(p_char8 data, v_buff_size size){ if(i > lastPos){ auto part = Part::createShared(Part::FUNCTION_VAR, oatpp::String((const char*)&data[lastPos], i - lastPos, true)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); }else{ auto part = Part::createShared(Part::FUNCTION_VAR, oatpp::String((v_buff_size)0)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); } lastPos = i + 1; @@ -92,7 +92,7 @@ std::shared_ptr Pattern::parse(p_char8 data, v_buff_size size){ if(i - lastPos > 0){ auto part = Part::createShared(Part::FUNCTION_CONST, oatpp::String((const char*)&data[lastPos], i - lastPos, true)); - result->m_parts->pushBack(part); + result->m_parts->push_back(part); } return result; @@ -123,21 +123,15 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) { oatpp::parser::Caret caret(url.getData(), url.getSize()); - if(m_parts->count() == 0){ - - if(caret.skipChar('/')){ - return false; - } - - return true; - + if (m_parts->empty()) { + return !caret.skipChar('/'); } - auto curr = m_parts->getFirstNode(); - - while(curr != nullptr){ - const std::shared_ptr& part = curr->getData(); - curr = curr->getNext(); + auto curr = std::begin(*m_parts); + const auto end = std::end(*m_parts); + while(curr != end){ + const std::shared_ptr& part = *curr; + ++curr; caret.skipChar('/'); if(part->function == Part::FUNCTION_CONST){ @@ -147,7 +141,7 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) { } if(caret.canContinue() && !caret.isAtChar('/')){ - if(caret.isAtChar('?') && (curr == nullptr || curr->getData()->function == Part::FUNCTION_ANY_END)) { + if(caret.isAtChar('?') && (curr == end || (*curr)->function == Part::FUNCTION_ANY_END)) { matchMap.m_tail = StringKeyLabel(url.getMemoryHandle(), caret.getCurrData(), caret.getDataSize() - caret.getPosition()); return true; } @@ -168,7 +162,7 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) { auto label = caret.putLabel(); v_char8 a = findSysChar(caret); if(a == '?') { - if(curr == nullptr || curr->getData()->function == Part::FUNCTION_ANY_END) { + if(curr == end || (*curr)->function == Part::FUNCTION_ANY_END) { matchMap.m_variables[part->text] = StringKeyLabel(url.getMemoryHandle(), label.getData(), label.getSize()); matchMap.m_tail = StringKeyLabel(url.getMemoryHandle(), caret.getCurrData(), caret.getDataSize() - caret.getPosition()); return true; @@ -183,20 +177,13 @@ bool Pattern::match(const StringKeyLabel& url, MatchMap& matchMap) { } caret.skipChar('/'); - if(caret.canContinue()){ - return false; - } - - return true; + return !caret.canContinue(); } oatpp::String Pattern::toString() { auto stream = oatpp::data::stream::ChunkedBuffer::createShared(); - auto curr = m_parts->getFirstNode(); - while (curr != nullptr) { - const std::shared_ptr& part = curr->getData(); - curr = curr->getNext(); + for (const std::shared_ptr& part : *m_parts) { if(part->function == Part::FUNCTION_CONST) { stream->writeSimple("/", 1); stream->writeSimple(part->text); diff --git a/src/oatpp/web/url/mapping/Pattern.hpp b/src/oatpp/web/url/mapping/Pattern.hpp index 1dceb366..6231c753 100644 --- a/src/oatpp/web/url/mapping/Pattern.hpp +++ b/src/oatpp/web/url/mapping/Pattern.hpp @@ -27,10 +27,9 @@ #include "oatpp/core/data/share/MemoryLabel.hpp" -#include "oatpp/core/collection/LinkedList.hpp" - #include "oatpp/core/parser/Caret.hpp" +#include #include namespace oatpp { namespace web { namespace url { namespace mapping { @@ -98,14 +97,10 @@ private: }; private: - std::shared_ptr>> m_parts; + std::shared_ptr>> m_parts{std::make_shared>>()}; private: v_char8 findSysChar(oatpp::parser::Caret& caret); public: - Pattern() - : m_parts(oatpp::collection::LinkedList>::createShared()) - {} -public: static std::shared_ptr createShared(){ return std::make_shared(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8458e4d7..4e67f5dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,8 +7,6 @@ add_executable(oatppAllTests oatpp/core/base/CommandLineArgumentsTest.hpp oatpp/core/base/LoggerTest.cpp oatpp/core/base/LoggerTest.hpp - oatpp/core/base/collection/LinkedListTest.cpp - oatpp/core/base/collection/LinkedListTest.hpp oatpp/core/base/memory/MemoryPoolTest.cpp oatpp/core/base/memory/MemoryPoolTest.hpp oatpp/core/base/memory/PerfTest.cpp diff --git a/test/oatpp/AllTestsMain.cpp b/test/oatpp/AllTestsMain.cpp index a2882fa3..8f4c1dd7 100644 --- a/test/oatpp/AllTestsMain.cpp +++ b/test/oatpp/AllTestsMain.cpp @@ -51,7 +51,6 @@ #include "oatpp/core/data/share/MemoryLabelTest.hpp" #include "oatpp/core/data/buffer/ProcessorTest.hpp" -#include "oatpp/core/base/collection/LinkedListTest.hpp" #include "oatpp/core/base/memory/MemoryPoolTest.hpp" #include "oatpp/core/base/memory/PerfTest.hpp" #include "oatpp/core/base/CommandLineArgumentsTest.hpp" @@ -82,8 +81,6 @@ void runTests() { OATPP_RUN_TEST(oatpp::test::memory::MemoryPoolTest); OATPP_RUN_TEST(oatpp::test::memory::PerfTest); - OATPP_RUN_TEST(oatpp::test::collection::LinkedListTest); - OATPP_RUN_TEST(oatpp::test::core::data::share::MemoryLabelTest); OATPP_RUN_TEST(oatpp::test::core::data::share::LazyStringMapTest); OATPP_RUN_TEST(oatpp::test::core::data::share::StringTemplateTest); diff --git a/test/oatpp/core/base/collection/LinkedListTest.cpp b/test/oatpp/core/base/collection/LinkedListTest.cpp deleted file mode 100644 index a2a584f1..00000000 --- a/test/oatpp/core/base/collection/LinkedListTest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************/ - -#include "LinkedListTest.hpp" - -#include "oatpp/core/Types.hpp" -#include "oatpp/core/collection/LinkedList.hpp" -#include "oatpp-test/Checker.hpp" -#include - -namespace oatpp { namespace test { namespace collection { - -namespace { - -class TestObject : public oatpp::base::Countable { -public: - SHARED_OBJECT_POOL(TestObject_Pool2, TestObject, 32) -public: - TestObject() - {} -public: - - static std::shared_ptr createShared2(){ - return std::make_shared(); - } - - static std::shared_ptr createShared(){ - return TestObject_Pool2::allocateShared(); - } - -}; - -void testListPerformance(v_int32 iterationsCount){ - - auto list = oatpp::collection::LinkedList>::createShared(); - - for(v_int32 i = 0; i < iterationsCount; i++){ - list->pushBack(TestObject::createShared()); - } - - auto curr = list->getFirstNode(); - while (curr != nullptr) { - auto data = curr->getData(); - curr = curr->getNext(); - } - -} - -void testStdListPerformance(v_int32 iterationsCount){ - - std::list> list; - - for(v_int32 i = 0; i < iterationsCount; i++){ - list.push_back(TestObject::createShared()); - } - - auto it = list.begin(); - while (it != list.end()) { - auto data = *it; - it++; - } - -} - -} - -void LinkedListTest::onRun() { - - - v_int32 iterationsCount = 100000; - - { - PerformanceChecker checker("oatpp::collection::LinkedList pushBack time"); - for(v_int32 i = 0; i < 10; i ++) { - testListPerformance(iterationsCount); - } - } - - { - PerformanceChecker checker("std::list pushBack time"); - for(v_int32 i = 0; i < 10; i ++) { - testStdListPerformance(iterationsCount); - } - } - -} - -}}} diff --git a/test/oatpp/core/base/collection/LinkedListTest.hpp b/test/oatpp/core/base/collection/LinkedListTest.hpp deleted file mode 100644 index 769ebd91..00000000 --- a/test/oatpp/core/base/collection/LinkedListTest.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************/ - -#ifndef oatpp_test_base_collection_LinkedListTest_hpp -#define oatpp_test_base_collection_LinkedListTest_hpp - -#include "oatpp-test/UnitTest.hpp" - -namespace oatpp { namespace test { namespace collection { - -class LinkedListTest : public UnitTest{ -public: - - LinkedListTest():UnitTest("TEST[oatpp::collection::LinkedListTest]"){} - void onRun() override; - -}; - -}}} - -#endif /* oatpp_test_base_collection_LinkedListTest_hpp */ diff --git a/test/oatpp/core/base/memory/PerfTest.cpp b/test/oatpp/core/base/memory/PerfTest.cpp index ec0d0b4d..444077eb 100644 --- a/test/oatpp/core/base/memory/PerfTest.cpp +++ b/test/oatpp/core/base/memory/PerfTest.cpp @@ -24,7 +24,6 @@ #include "PerfTest.hpp" -#include "oatpp/core/collection/LinkedList.hpp" #include "oatpp/core/Types.hpp" #include "oatpp/core/concurrency/Thread.hpp"