Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

uthread_prefix = "async_simple/uthread/internal/"
Expand Down
14 changes: 9 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
module(name = "com_github_async_simple")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest", dev_dependency = True)
bazel_dep(name = "google_benchmark", version = "1.8.5", repo_name = "com_google_benchmark", dev_dependency = True)

bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "bazel_skylib", version = "1.8.2")

bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True, repo_name = "com_google_googletest")
bazel_dep(name = "google_benchmark", version = "1.9.5", dev_dependency = True, repo_name = "com_google_benchmark")
bazel_dep(name = "boringssl", version = "0.20250311.0", dev_dependency = True)

bazel_dep(name = "rules_cc", version = "0.2.16")

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)
13 changes: 7 additions & 6 deletions async_simple/coro/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_library(
Expand All @@ -9,14 +10,14 @@ cc_library(
cc_test(
name = "async_simple_coro_test",
srcs = glob(["*.cpp"]),
deps = [
"//:async_simple",
"//async_simple/test:gtest_main",
":hdrs_dep",
],
copts = ASYNC_SIMPLE_COPTS + select({
"@platforms//os:windows": [],
# Clang gives incorrect warnings, See https://github.com/llvm/llvm-project/issues/56768
"//conditions:default": ["-Wno-unsequenced"],
})
}),
deps = [
":hdrs_dep",
"//:async_simple",
"//async_simple/test:gtest_main",
],
)
2 changes: 1 addition & 1 deletion async_simple/coro/test/GeneratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class GeneratorTest : public FUTURE_TESTBASE {

TEST_F(GeneratorTest, testIterator) {
size_t n = 15;
for (int j = 0; int i : fibonacci_sequence(n)) {
for (int j = 0; auto i : fibonacci_sequence(n)) {
EXPECT_EQ(i, fibonacci_expected[j++]);
}
}
Expand Down
12 changes: 6 additions & 6 deletions async_simple/coro/test/LazyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ TEST_F(LazyTest, testCollectAnyVariadicWithCancel) {
collectAny<SignalType::Terminate>(
my_sleep(10ms, SignalType::Terminate, false),
my_sleep(5s, SignalType::Terminate, true, false)));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand All @@ -1454,7 +1454,7 @@ TEST_F(LazyTest, testCollectAnyVariadicWithCancel) {
collectAny<SignalType::None>(
my_sleep(10ms, SignalType::None, false),
my_sleep(200ms, SignalType::None, false)));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand All @@ -1468,7 +1468,7 @@ TEST_F(LazyTest, testCollectAnyVariadicWithCancel) {
collectAny<SignalType::None>(
my_sleep(10ms, SignalType::None, false),
my_sleep(200ms, SignalType::Terminate)));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand All @@ -1491,7 +1491,7 @@ TEST_F(LazyTest, testCollectAnyWithCancel) {
v3.push_back(collectAny<SignalType::Terminate>(std::move(v1)));
v3.push_back(collectAny<SignalType::Terminate>(std::move(v2)));
auto result = co_await collectAny<SignalType::All>(std::move(v3));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand All @@ -1508,7 +1508,7 @@ TEST_F(LazyTest, testCollectAnyWithCancel) {
v3.push_back(collectAny<SignalType::Terminate>(std::move(v1)));
v3.push_back(collectAny<SignalType::None>(std::move(v2)));
auto result = co_await collectAny<SignalType::None>(std::move(v3));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand All @@ -1525,7 +1525,7 @@ TEST_F(LazyTest, testCollectAnyWithCancel) {
v3.push_back(collectAny<SignalType::Terminate>(std::move(v1)));
v3.push_back(collectAny<SignalType::None>(std::move(v2)));
auto result = co_await collectAny<SignalType::Terminate>(std::move(v3));
EXPECT_EQ(result.index(), 1);
EXPECT_EQ(result.index(), 1u);
auto slot2 = co_await CurrentSlot{};
EXPECT_EQ(slot, slot2);
}()
Expand Down
4 changes: 2 additions & 2 deletions async_simple/coro/test/ResumeByScheduleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ TEST(ResumeBySchedule, basic) {
std::unique_lock guard(mut);
cv.wait(guard, [&]() -> bool { return done_count == 100; });
cbs.Stop();
EXPECT_EQ(ex.checkin_count_, 0);
EXPECT_LE(ex.schedule_count_, 200);
EXPECT_EQ(ex.checkin_count_, 0u);
EXPECT_LE(ex.schedule_count_, 200u);
}

} // namespace coro
Expand Down
5 changes: 3 additions & 2 deletions async_simple/executors/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_test(
name = "async_simple_executor_test",
srcs = glob(["*.cpp"]),
copts = ASYNC_SIMPLE_COPTS,
deps = [
"//:async_simple",
"//async_simple/test:gtest_main",
],
copts = ASYNC_SIMPLE_COPTS,
],
)
2 changes: 1 addition & 1 deletion async_simple/executors/test/SimpleExecutorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ TEST(SimpleExecutorTest, testNormal) {
async_simple::util::move_only_function(std::move(move_only_functor)));
std::unique_lock<std::mutex> guard(mut);
cv.wait(guard, [&]() { return done_count == 2; });
EXPECT_EQ(sum, 30);
EXPECT_EQ(sum, 30u);
}
9 changes: 5 additions & 4 deletions async_simple/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_library(
name = "gtest_main",
srcs = ["dotest.cpp"],
hdrs = ["unittest.h"],
copts = ASYNC_SIMPLE_COPTS,
visibility = ["//visibility:public"],
deps = [
"//:simple_executors",
"@com_google_googletest//:gtest"
"@com_google_googletest//:gtest",
],
copts = ASYNC_SIMPLE_COPTS,
visibility = ["//visibility:public"],
)

cc_test(
name = "async_simple_test",
srcs = glob(["*Test.cpp"]),
copts = ASYNC_SIMPLE_COPTS,
deps = [
"//:async_simple",
"//async_simple/test:gtest_main",
],
copts = ASYNC_SIMPLE_COPTS,
)
2 changes: 1 addition & 1 deletion async_simple/test/CancellationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ TEST_F(CancellationTest, testDerivedSignal) {
SignalType::Terminate, [](SignalType type, Signal* signal) {
auto mySignal = dynamic_cast<MySignal*>(signal);
EXPECT_NE(mySignal, nullptr);
EXPECT_EQ(mySignal->myState, 1);
EXPECT_EQ(mySignal->myState, 1u);
});
mySignal->myState = 1;
mySignal->emits(SignalType::Terminate);
Expand Down
9 changes: 5 additions & 4 deletions async_simple/uthread/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_test(
name = "async_simple_uthread_test",
srcs = select({
"//bazel/config:async_simple_with_uthread" : glob(["*.cpp"]),
"//conditions:default" : [],
}),
"//bazel/config:async_simple_with_uthread": glob(["*.cpp"]),
"//conditions:default": [],
}),
copts = ASYNC_SIMPLE_COPTS,
deps = [
"//:async_simple",
"//async_simple/test:gtest_main",
],
copts = ASYNC_SIMPLE_COPTS,
)
2 changes: 1 addition & 1 deletion async_simple/uthread/test/UthreadAllocTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ TEST_F(UthreadAllocSwapTest, testSwitch) {
while (running) {
}

EXPECT_NE(get_stack_holder_count, 0);
EXPECT_NE(get_stack_holder_count, 0u);
while (!delete_stack_holder_count) {
}

Expand Down
3 changes: 2 additions & 1 deletion async_simple/util/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_test(
name = "async_simple_util_test",
srcs = glob(["*.cpp"]),
copts = ASYNC_SIMPLE_COPTS,
deps = [
"//:async_simple",
"//async_simple/test:gtest_main",
],
copts = ASYNC_SIMPLE_COPTS,
)
28 changes: 16 additions & 12 deletions benchmarks/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS")

cc_library(
name = "benchmark_main",
srcs = ["benchmark_main.cpp"],
hdrs = glob(["*.h", "*.hpp"]),
hdrs = glob([
"*.h",
"*.hpp",
]),
copts = ASYNC_SIMPLE_COPTS,
defines = select({
"//bazel/config:async_simple_with_uthread": ["ASYNC_SIMPLE_BENCHMARK_UTHREAD"],
"//conditions:default": [],
}),
deps = [
"//:async_simple",
"//:simple_executors",
"@com_google_benchmark//:benchmark",
],
defines = select({
"//bazel/config:async_simple_with_uthread" : ["ASYNC_SIMPLE_BENCHMARK_UTHREAD"],
"//conditions:default" : [],
}),
copts = ASYNC_SIMPLE_COPTS,
)

cc_binary(
name = "benchmarking",
srcs = [
"PureSwitch.bench.cpp",
"ReadFile.bench.cpp",
"CallDepth.bench.cpp",
"Lazy.bench.cpp",
"Future.bench.cpp",
"ThreadPool.bench.cpp",
"Lazy.bench.cpp",
"Mutex.bench.cpp",
"PureSwitch.bench.cpp",
"ReadFile.bench.cpp",
"SharedMutex.bench.cpp",
"SpinLock.bench.cpp",
"SharedMutex.bench.cpp"
"ThreadPool.bench.cpp",
] + select({
"//bazel/config:async_simple_with_uthread": ["Uthread.bench.cpp"],
"//conditions:default": [],
}),
deps = [":benchmark_main"],
copts = ASYNC_SIMPLE_COPTS,
deps = [":benchmark_main"],
)
Loading
Loading