Skip to content

Commit 8fbb757

Browse files
committed
updated to oatpp veraion 0.19.4
1 parent b6e061d commit 8fbb757

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

main/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ target_include_directories(${project_name}-lib
2323

2424
## link libs
2525

26-
find_package(oatpp 0.19.1 REQUIRED)
26+
find_package(oatpp 0.19.4 REQUIRED)
2727

2828
target_link_libraries(${project_name}-lib
2929
PUBLIC oatpp::oatpp

main/src/AppComponent.hpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@
2626
*/
2727
class AppComponent {
2828
public:
29-
29+
30+
/**
31+
* Create Async Executor
32+
*/
33+
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::async::Executor>, executor)([] {
34+
return std::make_shared<oatpp::async::Executor>(
35+
4 /* Data-Processing threads */,
36+
1 /* I/O threads */,
37+
1 /* Timer threads */
38+
);
39+
}());
40+
3041
/**
3142
* Create ConnectionProvider component which listens on the port
3243
*/
3344
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
3445
/* non_blocking connections should be used with AsyncHttpConnectionHandler for AsyncIO */
35-
return oatpp::network::server::SimpleTCPConnectionProvider::createShared(8000, true /* true for non_blocking */);
46+
return oatpp::network::server::SimpleTCPConnectionProvider::createShared(8000);
3647
}());
3748

3849
/**
@@ -47,8 +58,8 @@ class AppComponent {
4758
*/
4859
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::server::ConnectionHandler>, serverConnectionHandler)([] {
4960
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router); // get Router component
50-
/* Async ConnectionHandler for Async IO and Coroutine based endpoints */
51-
return oatpp::web::server::AsyncHttpConnectionHandler::createShared(router);
61+
OATPP_COMPONENT(std::shared_ptr<oatpp::async::Executor>, executor); // get Async executor component
62+
return oatpp::web::server::AsyncHttpConnectionHandler::createShared(router, executor);
5263
}());
5364

5465
/**

main/src/Logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
#include <iostream>
1212

1313
void Logger::log(v_int32 priority, const std::string& tag, const std::string& message) {
14-
oatpp::concurrency::SpinLock lock(m_atom);
14+
std::lock_guard<oatpp::concurrency::SpinLock> lock(m_lock);
1515
std::cout << tag << ":" << message << "\n";
1616
}

main/src/Logger.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919
*/
2020
class Logger : public oatpp::base::Logger {
2121
private:
22-
oatpp::concurrency::SpinLock::Atom m_atom;
22+
oatpp::concurrency::SpinLock m_lock;
2323
public:
2424

25-
Logger()
26-
: m_atom(false)
27-
{}
28-
2925
void log(v_int32 priority, const std::string& tag, const std::string& message) override;
3026

3127
};

main/src/Utils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ oatpp::String StaticFilesManager::getFile(const oatpp::String& path) {
3030
if(!path) {
3131
return nullptr;
3232
}
33+
std::lock_guard<oatpp::concurrency::SpinLock> lock(m_lock);
3334
auto& file = m_cache [path];
3435
if(file) {
3536
return file;

main/src/Utils.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
class StaticFilesManager {
1919
private:
2020
oatpp::String m_basePath;
21-
oatpp::concurrency::SpinLock::Atom m_atom;
21+
oatpp::concurrency::SpinLock m_lock;
2222
std::unordered_map<oatpp::String, oatpp::String> m_cache;
2323
private:
2424
oatpp::String getExtension(const oatpp::String& filename);
2525
public:
2626

2727
StaticFilesManager(const oatpp::String& basePath)
2828
: m_basePath(basePath)
29-
, m_atom(false)
3029
{}
3130

3231
oatpp::String getFile(const oatpp::String& path);

0 commit comments

Comments
 (0)