File tree Expand file tree Collapse file tree 6 files changed +20
-13
lines changed Expand file tree Collapse file tree 6 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ target_include_directories(${project_name}-lib
23
23
24
24
## link libs
25
25
26
- find_package (oatpp 0.19.1 REQUIRED )
26
+ find_package (oatpp 0.19.4 REQUIRED )
27
27
28
28
target_link_libraries (${project_name} -lib
29
29
PUBLIC oatpp::oatpp
Original file line number Diff line number Diff line change 26
26
*/
27
27
class AppComponent {
28
28
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
+
30
41
/* *
31
42
* Create ConnectionProvider component which listens on the port
32
43
*/
33
44
OATPP_CREATE_COMPONENT (std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
34
45
/* 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 );
36
47
}());
37
48
38
49
/* *
@@ -47,8 +58,8 @@ class AppComponent {
47
58
*/
48
59
OATPP_CREATE_COMPONENT (std::shared_ptr<oatpp::network::server::ConnectionHandler>, serverConnectionHandler)([] {
49
60
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 );
52
63
}());
53
64
54
65
/* *
Original file line number Diff line number Diff line change 11
11
#include < iostream>
12
12
13
13
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 );
15
15
std::cout << tag << " :" << message << " \n " ;
16
16
}
Original file line number Diff line number Diff line change 19
19
*/
20
20
class Logger : public oatpp ::base::Logger {
21
21
private:
22
- oatpp::concurrency::SpinLock::Atom m_atom ;
22
+ oatpp::concurrency::SpinLock m_lock ;
23
23
public:
24
24
25
- Logger ()
26
- : m_atom(false )
27
- {}
28
-
29
25
void log (v_int32 priority, const std::string& tag, const std::string& message) override ;
30
26
31
27
};
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ oatpp::String StaticFilesManager::getFile(const oatpp::String& path) {
30
30
if (!path) {
31
31
return nullptr ;
32
32
}
33
+ std::lock_guard<oatpp::concurrency::SpinLock> lock (m_lock);
33
34
auto & file = m_cache [path];
34
35
if (file) {
35
36
return file;
Original file line number Diff line number Diff line change 18
18
class StaticFilesManager {
19
19
private:
20
20
oatpp::String m_basePath;
21
- oatpp::concurrency::SpinLock::Atom m_atom ;
21
+ oatpp::concurrency::SpinLock m_lock ;
22
22
std::unordered_map<oatpp::String, oatpp::String> m_cache;
23
23
private:
24
24
oatpp::String getExtension (const oatpp::String& filename);
25
25
public:
26
26
27
27
StaticFilesManager (const oatpp::String& basePath)
28
28
: m_basePath(basePath)
29
- , m_atom(false )
30
29
{}
31
30
32
31
oatpp::String getFile (const oatpp::String& path);
You can’t perform that action at this time.
0 commit comments