move oatpp/core/provider/* --> oatpp/provider/*

This commit is contained in:
Leonid Stryzhevskyi 2024-04-23 03:40:49 +03:00
parent 36f298c8d4
commit 477b5b1af9
20 changed files with 83 additions and 82 deletions

View File

@ -67,6 +67,7 @@ OATPP_ASSERT(decoded == data)
| `oatpp/core/base/Environment.hpp` | `oatpp/Environment.hpp` |
| `oatpp/core/base/*` | `oatpp/base/*` |
| `oatpp/core/concurrency/*` | `oatpp/concurrency/*` |
| `oatpp/core/provider/*` | `oatpp/provider/*` |
### Namespaces

View File

@ -120,9 +120,6 @@ add_library(oatpp
oatpp/core/parser/Caret.hpp
oatpp/core/parser/ParsingError.cpp
oatpp/core/parser/ParsingError.hpp
oatpp/core/provider/Invalidator.hpp
oatpp/core/provider/Pool.hpp
oatpp/core/provider/Provider.hpp
oatpp/encoding/Base64.cpp
oatpp/encoding/Base64.hpp
oatpp/encoding/Hex.cpp
@ -193,6 +190,9 @@ add_library(oatpp
oatpp/orm/SchemaMigration.hpp
oatpp/orm/Transaction.cpp
oatpp/orm/Transaction.hpp
oatpp/provider/Invalidator.hpp
oatpp/provider/Pool.hpp
oatpp/provider/Provider.hpp
oatpp/utils/Binary.cpp
oatpp/utils/Binary.hpp
oatpp/utils/Conversion.cpp

View File

@ -87,7 +87,7 @@ public:
};
/**
* Provider of template variable-values based on the std::vector.
* TestProvider of template variable-values based on the std::vector.
*/
class VectorValueProvider : public ValueProvider {
private:
@ -98,7 +98,7 @@ public:
};
/**
* Provider of template variable-values based on the std::unordered_map.
* TestProvider of template variable-values based on the std::unordered_map.
*/
class MapValueProvider : public ValueProvider {
private:
@ -109,7 +109,7 @@ public:
};
/**
* Provider of template variable-values which returns the same value for all variables.
* TestProvider of template variable-values which returns the same value for all variables.
*/
class SingleValueProvider : public ValueProvider {
private:

View File

@ -25,7 +25,7 @@
#ifndef oatpp_network_ConnectionHandler_hpp
#define oatpp_network_ConnectionHandler_hpp
#include "oatpp/core/provider/Provider.hpp"
#include "oatpp/provider/Provider.hpp"
#include "oatpp/core/data/stream/Stream.hpp"
#include <unordered_map>

View File

@ -26,7 +26,7 @@
#define oatpp_network_ConnectionPool_hpp
#include "ConnectionProvider.hpp"
#include "oatpp/core/provider/Pool.hpp"
#include "oatpp/provider/Pool.hpp"
namespace oatpp { namespace network {

View File

@ -27,7 +27,7 @@
#include "oatpp/core/data/share/MemoryLabel.hpp"
#include "oatpp/core/data/stream/Stream.hpp"
#include "oatpp/core/provider/Provider.hpp"
#include "oatpp/provider/Provider.hpp"
#include <unordered_map>

View File

@ -28,7 +28,7 @@
#include "oatpp/network/Address.hpp"
#include "oatpp/network/ConnectionProvider.hpp"
#include "oatpp/core/provider/Invalidator.hpp"
#include "oatpp/provider/Invalidator.hpp"
#include "oatpp/Types.hpp"
namespace oatpp { namespace network { namespace tcp { namespace client {
@ -68,7 +68,7 @@ public:
}
/**
* Implements &id:oatpp::provider::Provider::stop;. Here does nothing.
* Implements &id:oatpp::provider::TestProvider::stop;. Here does nothing.
*/
void stop() override {
// DO NOTHING

View File

@ -31,7 +31,7 @@
namespace oatpp { namespace network { namespace virtual_ { namespace client {
/**
* Provider of "virtual" connections for client.
* TestProvider of "virtual" connections for client.
* See &id:oatpp::network::virtual_::Interface;, &id:oatpp::network::virtual_::Socket; <br>
* Extends &id:oatpp::network::ClientConnectionProvider;.
*/
@ -78,7 +78,7 @@ public:
}
/**
* Implementation of &id:oatpp::provider::Provider::Stop; method.
* Implementation of &id:oatpp::provider::TestProvider::Stop; method.
*/
void stop() override;

View File

@ -31,7 +31,7 @@
namespace oatpp { namespace network { namespace virtual_ { namespace server {
/**
* Provider of "virtual" connections.
* TestProvider of "virtual" connections.
* See &id:oatpp::network::virtual_::Interface;, &id:oatpp::network::virtual_::Socket; <br>
* Extends &id:oatpp::network::ServerConnectionProvider;.
*/

View File

@ -26,7 +26,7 @@
#define oatpp_orm_QueryResult_hpp
#include "Connection.hpp"
#include "oatpp/core/provider/Provider.hpp"
#include "oatpp/provider/Provider.hpp"
#include "oatpp/Types.hpp"
namespace oatpp { namespace orm {

View File

@ -38,7 +38,7 @@ template<class TResource, class AcquisitionProxyImpl>
class PoolTemplate; // FWD
/**
* Pool acquisition proxy template.
* TestPool acquisition proxy template.
* @tparam TResource - abstract resource interface type, Ex.: `IOStream`.
* @tparam AcquisitionProxyImpl - implementation of proxy.
*/
@ -47,7 +47,7 @@ class AcquisitionProxy : public TResource {
friend PoolTemplate<TResource, AcquisitionProxyImpl>;
public:
/**
* Convenience typedef for Pool.
* Convenience typedef for TestPool.
*/
typedef PoolTemplate<TResource, AcquisitionProxyImpl> PoolInstance;
private:
@ -406,9 +406,9 @@ public:
};
/**
* Pool template class.
* TestPool template class.
* @tparam TProvider - base class for pool to inherit, ex.: ServerConnectionProvider.
* @tparam TResource - abstract resource interface type, Ex.: `IOStream`. Must be the same as a return-type of Provider.
* @tparam TResource - abstract resource interface type, Ex.: `IOStream`. Must be the same as a return-type of TestProvider.
* @tparam AcquisitionProxyImpl - implementation of &l:AcquisitionProxy;.
*/
template<class TProvider, class TResource, class AcquisitionProxyImpl>
@ -440,12 +440,12 @@ protected:
public:
/**
* Create shared Pool.
* Create shared TestPool.
* @param provider - resource provider.
* @param maxResources - max resource count in the pool.
* @param maxResourceTTL - max time-to-live for unused resource in the pool.
* @param timeout - optional timeout on &l:Pool::get (); and &l:Pool::getAsync (); operations.
* @return - `std::shared_ptr` of `Pool`.
* @param timeout - optional timeout on &l:TestPool::get (); and &l:TestPool::getAsync (); operations.
* @return - `std::shared_ptr` of `TestPool`.
*/
static std::shared_ptr<Pool> createShared(const std::shared_ptr<TProvider>& provider,
v_int64 maxResources,

View File

@ -31,7 +31,7 @@
namespace oatpp { namespace web { namespace protocol { namespace http { namespace encoding {
/**
* Provider of encoding or decoding &id:oatpp::data::buffer::Processor;.
* TestProvider of encoding or decoding &id:oatpp::data::buffer::Processor;.
*/
class EncoderProvider {
public:

View File

@ -48,10 +48,6 @@ add_executable(oatppAllTests
oatpp/core/data/stream/BufferStreamTest.hpp
oatpp/core/parser/CaretTest.cpp
oatpp/core/parser/CaretTest.hpp
oatpp/core/provider/PoolTemplateTest.cpp
oatpp/core/provider/PoolTemplateTest.hpp
oatpp/core/provider/PoolTest.cpp
oatpp/core/provider/PoolTest.hpp
oatpp/encoding/Base64Test.cpp
oatpp/encoding/Base64Test.hpp
oatpp/encoding/UnicodeTest.cpp
@ -80,6 +76,10 @@ add_executable(oatppAllTests
oatpp/network/virtual_/InterfaceTest.hpp
oatpp/network/virtual_/PipeTest.cpp
oatpp/network/virtual_/PipeTest.hpp
oatpp/provider/PoolTemplateTest.cpp
oatpp/provider/PoolTemplateTest.hpp
oatpp/provider/PoolTest.cpp
oatpp/provider/PoolTest.hpp
oatpp/web/ClientRetryTest.cpp
oatpp/web/ClientRetryTest.hpp
oatpp/web/FullAsyncClientTest.cpp

View File

@ -30,8 +30,8 @@
#include "oatpp/encoding/UrlTest.hpp"
#include "oatpp/core/parser/CaretTest.hpp"
#include "oatpp/core/provider/PoolTest.hpp"
#include "oatpp/core/provider/PoolTemplateTest.hpp"
#include "oatpp/provider/PoolTest.hpp"
#include "oatpp/provider/PoolTemplateTest.hpp"
#include "oatpp/async/ConditionVariableTest.hpp"
#include "oatpp/async/LockTest.hpp"
@ -123,8 +123,8 @@ void runTests() {
OATPP_RUN_TEST(oatpp::async::LockTest);
OATPP_RUN_TEST(oatpp::test::parser::CaretTest);
OATPP_RUN_TEST(oatpp::test::core::provider::PoolTest);
OATPP_RUN_TEST(oatpp::test::core::provider::PoolTemplateTest);
OATPP_RUN_TEST(oatpp::provider::PoolTest);
OATPP_RUN_TEST(oatpp::provider::PoolTemplateTest);
OATPP_RUN_TEST(oatpp::json::EnumTest);
OATPP_RUN_TEST(oatpp::json::BooleanTest);

View File

@ -26,17 +26,17 @@
#include "PoolTemplateTest.hpp"
#include <future>
#include "oatpp/core/provider/Pool.hpp"
#include "oatpp/provider/Pool.hpp"
#include "oatpp/async/Executor.hpp"
namespace oatpp { namespace test { namespace core { namespace provider {
namespace oatpp { namespace provider {
namespace {
struct Resource {
};
class Provider : public oatpp::provider::Provider<Resource> {
class TestProvider : public oatpp::provider::Provider<Resource> {
private:
class ResourceInvalidator : public oatpp::provider::Invalidator<Resource> {
@ -60,10 +60,10 @@ public:
class GetCoroutine : public oatpp::async::CoroutineWithResult<GetCoroutine, const oatpp::provider::ResourceHandle<Resource>&> {
private:
Provider* m_provider;
TestProvider* m_provider;
public:
GetCoroutine(Provider* provider)
GetCoroutine(TestProvider* provider)
: m_provider(provider)
{}
@ -77,7 +77,7 @@ public:
}
void stop() override {
OATPP_LOGD("Provider", "stop()")
OATPP_LOGD("TestProvider", "stop()")
}
};
@ -90,9 +90,9 @@ struct AcquisitionProxy : public oatpp::provider::AcquisitionProxy<Resource, Acq
};
struct Pool : public oatpp::provider::PoolTemplate<Resource, AcquisitionProxy> {
struct TestPool : public oatpp::provider::PoolTemplate<Resource, AcquisitionProxy> {
Pool(const std::shared_ptr<Provider>& provider, v_int64 maxResources, v_int64 maxResourceTTL, const std::chrono::duration<v_int64, std::micro>& timeout)
TestPool(const std::shared_ptr<TestProvider>& provider, v_int64 maxResources, v_int64 maxResourceTTL, const std::chrono::duration<v_int64, std::micro>& timeout)
: oatpp::provider::PoolTemplate<Resource, AcquisitionProxy>(provider, maxResources, maxResourceTTL, timeout)
{}
@ -104,11 +104,11 @@ struct Pool : public oatpp::provider::PoolTemplate<Resource, AcquisitionProxy> {
return oatpp::provider::PoolTemplate<Resource, AcquisitionProxy>::getAsync(_this);
}
static std::shared_ptr<PoolTemplate> createShared(const std::shared_ptr<Provider>& provider,
static std::shared_ptr<PoolTemplate> createShared(const std::shared_ptr<TestProvider>& provider,
v_int64 maxResources,
const std::chrono::duration<v_int64, std::micro>& maxResourceTTL,
const std::chrono::duration<v_int64, std::micro>& timeout) {
auto ptr = std::make_shared<Pool>(provider, maxResources, maxResourceTTL.count(), timeout);
auto ptr = std::make_shared<TestPool>(provider, maxResources, maxResourceTTL.count(), timeout);
startCleanupTask(ptr);
return ptr;
}
@ -127,7 +127,7 @@ public:
{}
Action act() override {
return Pool::getAsync(m_pool).callbackTo(&ClientCoroutine::onGet);
return TestPool::getAsync(m_pool).callbackTo(&ClientCoroutine::onGet);
}
Action onGet(const oatpp::provider::ResourceHandle<Resource>& resource) {
@ -140,40 +140,40 @@ public:
}
void PoolTemplateTest::onRun() {
const auto provider = std::make_shared<Provider>();
const auto provider = std::make_shared<TestProvider>();
const v_int64 maxResources = 1;
{
OATPP_LOGD(TAG, "Synchronously with timeout")
auto poolTemplate = Pool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
oatpp::provider::ResourceHandle<Resource> resource = Pool::get(poolTemplate);
oatpp::provider::ResourceHandle<Resource> resource = TestPool::get(poolTemplate);
OATPP_ASSERT(resource != nullptr)
OATPP_ASSERT(Pool::get(poolTemplate) == nullptr)
OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr)
poolTemplate->stop();
OATPP_ASSERT(Pool::get(poolTemplate) == nullptr)
OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr)
}
{
OATPP_LOGD(TAG, "Synchronously without timeout")
auto poolTemplate = Pool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());
oatpp::provider::ResourceHandle<Resource> resource = Pool::get(poolTemplate);
oatpp::provider::ResourceHandle<Resource> resource = TestPool::get(poolTemplate);
OATPP_ASSERT(resource != nullptr)
std::future<oatpp::provider::ResourceHandle<Resource>> futureResource = std::async(std::launch::async, [&poolTemplate]() {
return Pool::get(poolTemplate);
return TestPool::get(poolTemplate);
});
OATPP_ASSERT(futureResource.wait_for(std::chrono::seconds(1)) == std::future_status::timeout)
poolTemplate->stop();
OATPP_ASSERT(Pool::get(poolTemplate) == nullptr)
OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr)
}
{
OATPP_LOGD(TAG, "Asynchronously with timeout")
oatpp::async::Executor executor(1, 1, 1);
auto poolTemplate = Pool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500));
oatpp::provider::ResourceHandle<Resource> resourceHandle;
{
@ -202,9 +202,9 @@ void PoolTemplateTest::onRun() {
{
OATPP_LOGD(TAG, "Asynchronously without timeout")
oatpp::async::Executor executor(1, 1, 1);
auto poolTemplate = Pool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());
auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero());
oatpp::provider::ResourceHandle<Resource> resource = Pool::get(poolTemplate);
oatpp::provider::ResourceHandle<Resource> resource = TestPool::get(poolTemplate);
OATPP_ASSERT(resource != nullptr)
std::promise<oatpp::provider::ResourceHandle<Resource>> promise;
@ -218,4 +218,4 @@ void PoolTemplateTest::onRun() {
}
}
}}}}
}}

View File

@ -23,14 +23,14 @@
*
***************************************************************************/
#ifndef oatpp_test_provider_PoolTemplateTest_hpp
#define oatpp_test_provider_PoolTemplateTest_hpp
#ifndef oatpp_provider_PoolTemplateTest_hpp
#define oatpp_provider_PoolTemplateTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace core { namespace provider {
namespace oatpp { namespace provider {
class PoolTemplateTest : public UnitTest{
class PoolTemplateTest : public oatpp::test::UnitTest{
public:
PoolTemplateTest():UnitTest("TEST[provider::PoolTemplateTest]"){}
@ -38,7 +38,7 @@ public:
};
}}}}
}}
#endif //oatpp_test_provider_PoolTemplateTest_hpp
#endif //oatpp_provider_PoolTemplateTest_hpp

View File

@ -24,12 +24,12 @@
#include "PoolTest.hpp"
#include "oatpp/core/provider/Pool.hpp"
#include "oatpp/provider/Pool.hpp"
#include "oatpp/async/Executor.hpp"
#include <thread>
namespace oatpp { namespace test { namespace core { namespace provider {
namespace oatpp { namespace provider {
namespace {
@ -57,7 +57,7 @@ public:
};
class Provider : public oatpp::provider::Provider<Resource> {
class TestProvider : public oatpp::provider::Provider<Resource> {
private:
class ResourceInvalidator : public oatpp::provider::Invalidator<Resource> {
@ -85,10 +85,10 @@ public:
class GetCoroutine : public oatpp::async::CoroutineWithResult<GetCoroutine, const oatpp::provider::ResourceHandle<Resource>&> {
private:
Provider* m_provider;
TestProvider* m_provider;
public:
GetCoroutine(Provider* provider)
GetCoroutine(TestProvider* provider)
: m_provider(provider)
{}
@ -105,7 +105,7 @@ public:
}
void stop() override {
OATPP_LOGD("Provider", "stop()")
OATPP_LOGD("TestProvider", "stop()")
}
v_int64 getIdCounter() {
@ -128,17 +128,17 @@ struct AcquisitionProxy : public oatpp::provider::AcquisitionProxy<Resource, Acq
};
typedef oatpp::provider::Pool<oatpp::provider::Provider<Resource>, Resource, AcquisitionProxy> Pool;
typedef oatpp::provider::Pool<oatpp::provider::Provider<Resource>, Resource, AcquisitionProxy> TestPool;
class ClientCoroutine : public oatpp::async::Coroutine<ClientCoroutine> {
private:
std::shared_ptr<Pool> m_pool;
std::shared_ptr<TestPool> m_pool;
oatpp::provider::ResourceHandle<Resource> m_resource;
bool m_invalidate;
public:
ClientCoroutine(const std::shared_ptr<Pool>& pool, bool invalidate)
ClientCoroutine(const std::shared_ptr<TestPool>& pool, bool invalidate)
: m_pool(pool)
, m_invalidate(invalidate)
{}
@ -161,7 +161,7 @@ public:
};
void clientMethod(std::shared_ptr<Pool> pool, bool invalidate) {
void clientMethod(std::shared_ptr<TestPool> pool, bool invalidate) {
auto resource = pool->get();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(invalidate) {
@ -175,8 +175,8 @@ void PoolTest::onRun() {
oatpp::async::Executor executor(10, 1, 1);
auto provider = std::make_shared<Provider>();
auto pool = Pool::createShared(provider, 10, std::chrono::seconds(2));
auto provider = std::make_shared<TestProvider>();
auto pool = TestPool::createShared(provider, 10, std::chrono::seconds(2));
std::list<std::thread> threads;
@ -193,7 +193,7 @@ void PoolTest::onRun() {
OATPP_ASSERT(pool->getCounter() == 10)
OATPP_LOGD(TAG, "Waiting...")
std::this_thread::sleep_for(std::chrono::seconds(10));
OATPP_LOGD(TAG, "Pool counter=%ld", pool->getCounter())
OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 0)
OATPP_LOGD(TAG, "Run 2")
@ -208,7 +208,7 @@ void PoolTest::onRun() {
OATPP_ASSERT(pool->getCounter() == 10)
OATPP_LOGD(TAG, "Waiting...")
std::this_thread::sleep_for(std::chrono::seconds(10));
OATPP_LOGD(TAG, "Pool counter=%ld", pool->getCounter())
OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter())
OATPP_ASSERT(pool->getCounter() == 0)
for(std::thread& thread : threads) {
@ -230,4 +230,4 @@ void PoolTest::onRun() {
}
}}}}
}}

View File

@ -22,14 +22,14 @@
*
***************************************************************************/
#ifndef oatpp_test_provider_PoolTest_hpp
#define oatpp_test_provider_PoolTest_hpp
#ifndef oatpp_provider_PoolTest_hpp
#define oatpp_provider_PoolTest_hpp
#include "oatpp-test/UnitTest.hpp"
namespace oatpp { namespace test { namespace core { namespace provider {
namespace oatpp { namespace provider {
class PoolTest : public UnitTest{
class PoolTest : public oatpp::test::UnitTest{
public:
PoolTest():UnitTest("TEST[provider::PoolTest]"){}
@ -37,7 +37,7 @@ public:
};
}}}}
}}
#endif //oatpp_test_provider_PoolTest_hpp
#endif //oatpp_provider_PoolTest_hpp