Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync coro channel #633

Merged
merged 10 commits into from
Oct 31, 2024
4 changes: 2 additions & 2 deletions .github/workflows/linux_llvm_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
./test_metric

llvm-profdata merge -sparse test_cinatra-*.profraw -o test_cinatra.profdata
llvm-cov show test_cinatra -object test_corofile -object test_time_util -object test_http_parse -object test_metric -instr-profile=test_cinatra.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="example|asio|cmdline|async_simple|tests" -show-instantiations=false
llvm-cov show -object test_cinatra -object test_corofile -object test_time_util -object test_http_parse -object test_metric -instr-profile=test_cinatra.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="example|asio|cmdline|async_simple|tests" -show-instantiations=false
echo "Done!"

- name: Upload Coverage Results
Expand All @@ -58,7 +58,7 @@ jobs:
echo "Code Coverage Report" > tmp.log
echo "for detail, [goto summary](https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{github.run_id}}) download Artifacts `llvm-cov`" >> tmp.log
echo "\`\`\`" >> tmp.log
llvm-cov report test_cinatra -object test_corofile -object test_time_util -object test_http_parse -instr-profile=test_cinatra.profdata -ignore-filename-regex="example|asio|cmdline|async_simple|tests" -show-region-summary=false >> tmp.log
llvm-cov report -object test_cinatra -object test_corofile -object test_time_util -object test_http_parse -instr-profile=test_cinatra.profdata -ignore-filename-regex="example|asio|cmdline|async_simple|tests" -show-region-summary=false >> tmp.log
echo "\`\`\`" >> tmp.log

- name: Create Comment
Expand Down
11 changes: 5 additions & 6 deletions include/cinatra/ylt/coro_io/coro_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,11 @@ post(Func func,
}

template <typename R>
struct coro_channel
: public asio::experimental::channel<void(std::error_code, R)> {
struct channel : public asio::experimental::channel<void(std::error_code, R)> {
using return_type = R;
using ValueType = std::pair<std::error_code, R>;
using asio::experimental::channel<void(std::error_code, R)>::channel;
coro_channel(coro_io::ExecutorWrapper<> *executor, size_t capacity)
channel(coro_io::ExecutorWrapper<> *executor, size_t capacity)
: executor_(executor),
asio::experimental::channel<void(std::error_code, R)>(
executor->get_asio_executor(), capacity) {}
Expand All @@ -380,17 +379,17 @@ struct coro_channel
};

template <typename R>
inline coro_channel<R> create_channel(
inline channel<R> create_channel(
size_t capacity,
coro_io::ExecutorWrapper<> *executor = coro_io::get_global_executor()) {
return coro_channel<R>(executor, capacity);
return channel<R>(executor, capacity);
}

template <typename R>
inline auto create_shared_channel(
size_t capacity,
coro_io::ExecutorWrapper<> *executor = coro_io::get_global_executor()) {
return std::make_shared<coro_channel<R>>(executor, capacity);
return std::make_shared<channel<R>>(executor, capacity);
}

template <typename T>
Expand Down
3 changes: 3 additions & 0 deletions include/cinatra/ylt/metric/dynamic_metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <thread>

#include "metric.hpp"
#include "thread_local_value.hpp"
#if __has_include("ylt/util/type_traits.h")
#include "ylt/util/map_sharded.hpp"
#else
Expand All @@ -12,6 +13,8 @@ namespace ylt::metric {

class dynamic_metric : public metric_t {
public:
static inline auto g_user_metric_label_count =
new thread_local_value<int64_t>(std::thread::hardware_concurrency());
using metric_t::metric_t;
};

Expand Down
2 changes: 0 additions & 2 deletions include/cinatra/ylt/metric/metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ struct metric_filter_options {
class metric_t {
public:
static inline std::atomic<int64_t> g_user_metric_count = 0;
static inline auto g_user_metric_label_count =
new thread_local_value<int64_t>(std::thread::hardware_concurrency());
metric_t() = default;
metric_t(MetricType type, std::string name, std::string help)
: type_(type),
Expand Down
2 changes: 1 addition & 1 deletion include/cinatra/ylt/metric/system_metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ inline void stat_metric() {
system_metric_manager::instance().get_metric_static<gauge_t>(
"ylt_user_metric_labels");
user_metric_label_count->update(
metric::metric_t::g_user_metric_label_count->value());
dynamic_metric::g_user_metric_label_count->value());
}

inline void ylt_stat() {
Expand Down
Loading