Procházet zdrojové kódy

兼容clang,放弃同步测试cinatra

3.0.0
tearshark před 9 měsíci
rodič
revize
ef9d7162ba

+ 4
- 4
CMakeLists.txt Zobrazit soubor

@@ -40,9 +40,9 @@ if(${LIBRF_COMPILER_SETTING} STREQUAL "msvc")
endif()
elseif ("${LIBRF_COMPILER_SETTING}" STREQUAL "clang_on_msvc")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /EHsc") #VS2022
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /EHsc -Wno-unused-private-field") #VS2022
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /EHsc") #VS2019
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /EHsc -Wno-unused-private-field") #VS2019
endif()
elseif ("${LIBRF_COMPILER_SETTING}" STREQUAL "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a -fcoroutines-ts -stdlib=libstdc++")
@@ -82,8 +82,8 @@ if(${LIBRF_COMPILER_SETTING} STREQUAL "msvc")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/W3 /WX /MP /GS- /Gm- /Ox /Ob2 /Oy /Oi /Os /GT /EHsc /Zc:inline")
set(CMAKE_CXX_FLAGS_RELEASE "/W3 /WX /MP /GS- /Gm- /Ox /Ob2 /Oy /Oi /Os /GT /EHsc /Zc:inline")
elseif ("${LIBRF_COMPILER_SETTING}" STREQUAL "clang_on_msvc")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/W3 /WX /GS- /Ox /Ob2 /Oy /Oi /Os /EHsc /Zc:inline")
set(CMAKE_CXX_FLAGS_RELEASE "/W3 /WX /GS- /Ox /Ob2 /Oy /Oi /Os /EHsc /Zc:inline")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/W3 /GS- /Ox /Ob2 /Oy /Oi /Os /EHsc /Zc:inline")
set(CMAKE_CXX_FLAGS_RELEASE "/W3 /GS- /Ox /Ob2 /Oy /Oi /Os /EHsc /Zc:inline")
elseif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb")

+ 2
- 2
benchmark/benchmark_async_mem.cpp Zobrazit soubor

@@ -36,8 +36,8 @@ void resumable_main_benchmark_mem(bool wait_key)
}
}
//clang : 平均 210字节
//msvc : 平均600字节
//clang : 平均 256 字节
//msvc : 平均 320 字节(vs2022,17.7.4)
#if LIBRF_TUTORIAL_STAND_ALONE
int main()

+ 0
- 67
benchmark/test_async_cinatra_client.cpp Zobrazit soubor

@@ -1,67 +0,0 @@
//依赖 https://github.com/tearshark/modern_cb 项目
//依赖 https://github.com/tearshark/librf 项目
//依赖 https://github.com/qicosmos/cinatra 项目

#pragma warning(disable : 4996)
#include <iostream>
#include "../../cinatra/include/cinatra.hpp"
#include "librf/librf.h"
#include "use_librf.h"

using namespace librf;
using namespace cinatra;

void test_async_cinatra_client()
{
std::string uri = "http://www.baidu.com";
std::string uri1 = "http://cn.bing.com";
std::string uri2 = "https://www.baidu.com";
std::string uri3 = "https://cn.bing.com";

GO
{
auto client = cinatra::client_factory::instance().new_client();
response_data data = co_await client->async_get(uri, use_librf);
print(data.resp_body);
};

GO
{
auto client = cinatra::client_factory::instance().new_client();
response_data data = co_await client->async_get(uri1, use_librf);
print(data.resp_body);
};

GO
{
auto client = cinatra::client_factory::instance().new_client();
response_data data = co_await client->async_post(uri, "hello", use_librf);
print(data.resp_body);
};

#ifdef CINATRA_ENABLE_SSL
GO
{
auto client = cinatra::client_factory::instance().new_client();
response_data data = co_await client->async_get(uri2, use_librf);
print(data.resp_body);
};

GO
{
auto client = cinatra::client_factory::instance().new_client();
response_data data = co_await client->async_get(uri3, use_librf);
print(data.resp_body);
};
#endif

librf::this_scheduler()->run_until_notask();
}

#if LIBRF_TUTORIAL_STAND_ALONE
int main()
{
test_async_cinatra_client();
return 0;
}
#endif

Načítá se…
Zrušit
Uložit