From e0b4094c7f78f8e062ac9880b9daa989dcb90b9d Mon Sep 17 00:00:00 2001 From: dragon-zhang Date: Tue, 17 Dec 2024 15:34:23 +0800 Subject: [PATCH] optimize README.md --- .github/workflows/ci.yml | 2 ++ .github/workflows/coverage.yml | 37 +++++++++++++++++++++++++++ README.md | 7 +++++ core/src/common/macros.rs | 2 +- core/src/common/mod.rs | 8 +----- core/src/common/ordered_work_steal.rs | 7 ++--- 6 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5950f529..1e13d861 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,11 @@ on: push: paths-ignore: - '**.md' + - '**.png' pull_request: paths-ignore: - '**.md' + - '**.png' env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..8ff6440e --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,37 @@ +name: Code Coverage + +on: + push: + paths-ignore: + - '**.md' + - '**.png' + pull_request: + paths-ignore: + - '**.md' + - '**.png' + +env: + CARGO_TERM_COLOR: always + +jobs: + coverage: + name: Run cargo coverage + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.81.0 + profile: minimal + override: true + components: llvm-tools-preview + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && sudo -u runner /home/runner/.cargo/bin/cargo llvm-cov --all-features --release --workspace --lcov --output-path lcov.info" + - name: Upload coverage to Codecov + run: bash <(curl -s https://codecov.io/bash) -f lcov.info -t ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 87a48809..a2198501 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # open-coroutine +[![crates.io](https://img.shields.io/crates/v/open-coroutine.svg)](https://crates.io/crates/open-coroutine) +[![LICENSE](https://img.shields.io/github/license/acl-dev/open-coroutine.svg?style=flat-square)](https://github.com/acl-dev/open-coroutine/blob/master/LICENSE-APACHE) +[![Build Status](https://github.com/acl-dev/open-coroutine/workflows/CI/badge.svg)](https://github.com/acl-dev/open-coroutine/actions) +[![Codecov](https://codecov.io/github/acl-dev/open-coroutine/graph/badge.svg?token=MSM3R7CBEX)](https://codecov.io/github/acl-dev/open-coroutine) +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/acl-dev/open-coroutine.svg)](http://isitmaintained.com/project/acl-dev/open-coroutine "Average time to resolve an issue") +[![Percentage of issues still open](http://isitmaintained.com/badge/open/acl-dev/open-coroutine.svg)](http://isitmaintained.com/project/acl-dev/open-coroutine "Percentage of issues still open") + The `open-coroutine` is a simple, efficient and generic stackful-coroutine library.
diff --git a/core/src/common/macros.rs b/core/src/common/macros.rs index 56d34fb1..4d1d62ef 100644 --- a/core/src/common/macros.rs +++ b/core/src/common/macros.rs @@ -1,4 +1,4 @@ -/// Check for help information. +//! Check for help information. /// Constructs an event at the trace level. #[allow(unused_macros)] diff --git a/core/src/common/mod.rs b/core/src/common/mod.rs index 42dfbb44..f92e005f 100644 --- a/core/src/common/mod.rs +++ b/core/src/common/mod.rs @@ -79,13 +79,7 @@ pub mod work_steal; /// for i in 0..2 { /// local1.push_with_priority(i, i); /// } -/// for i in 0..2 { -/// assert_eq!(local1.pop(), Some(i)); -/// } -/// for i in (2..6).rev() { -/// assert_eq!(local1.pop(), Some(i)); -/// } -/// for i in 6..8 { +/// for i in 0..8 { /// assert_eq!(local1.pop(), Some(i)); /// } /// assert_eq!(local0.pop(), None); diff --git a/core/src/common/ordered_work_steal.rs b/core/src/common/ordered_work_steal.rs index c9293d3f..30fb3af3 100644 --- a/core/src/common/ordered_work_steal.rs +++ b/core/src/common/ordered_work_steal.rs @@ -338,10 +338,7 @@ impl<'l, T: Debug> OrderedLocalQueue<'l, T> { /// local1.push_with_priority(i, i); /// } /// assert_eq!(local1.len(), 2); - /// for i in 0..2 { - /// assert_eq!(local1.pop(), Some(i)); - /// } - /// for i in (2..6).rev() { + /// for i in 0..6 { /// assert_eq!(local1.pop(), Some(i)); /// } /// assert_eq!(local0.pop(), None); @@ -374,7 +371,7 @@ impl<'l, T: Debug> OrderedLocalQueue<'l, T> { //不能偷自己 continue; } - for entry in another.iter().rev() { + for entry in another { let worker = entry.value(); if worker.is_empty() { //其他队列为空