Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion include/beman/execution/detail/bulk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_BULK
#define INCLUDED_BEMAN_EXECUTION_DETAIL_BULK

#include "beman/execution/detail/sender_adaptor.hpp"
#include "beman/execution/detail/sender_adaptor_closure.hpp"
#include <beman/execution/detail/get_completion_signatures.hpp>
#include <beman/execution/detail/meta_combine.hpp>
#include <beman/execution/detail/meta_unique.hpp>
Expand All @@ -29,7 +31,13 @@
#include <beman/execution/detail/suppress_push.hpp>
namespace beman::execution::detail {

struct bulk_t {
struct bulk_t : ::beman::execution::sender_adaptor_closure<bulk_t> {

template <class Shape, class f>
requires(std::is_integral_v<Shape> && ::beman::execution::detail::movable_value<f>)
auto operator()(Shape&& shape, f&& fun) const {
return beman::execution::detail::sender_adaptor{*this, std::forward<Shape>(shape), std::forward<f>(fun)};
}

template <class Sender, class Shape, class f>
requires(::beman::execution::sender<Sender> && std::is_integral_v<Shape> &&
Expand Down
14 changes: 7 additions & 7 deletions tests/beman/execution/exec-bulk.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace {
auto test_bulk() {
auto b0 = test_std::bulk(test_std::just(), 1, [](int) {});
auto b0 = test_std::just() | test_std::bulk(1, [](int) {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd to replace existing tests to cover new functionality. I’m aware that the new notation effectively calls into the original formulation and, this, implicitly tests what was previously tested. I tend to build test such that
the fundation is first tested separately.

Would it be viable to create new tests instead of modifying existing ones?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I reused the existing tests, but now implemented them using the pipe operator.


static_assert(test_std::sender<decltype(b0)>);
auto b0_env = test_std::get_env(b0);
Expand All @@ -25,7 +25,7 @@ auto test_bulk() {

int counter = 0;

auto b1 = test_std::bulk(test_std::just(), 5, [&](int i) { counter += i; });
auto b1 = test_std::just() | test_std::bulk(5, [&](int i) { counter += i; });

static_assert(test_std::sender<decltype(b1)>);
auto b1_env = test_std::get_env(b0);
Expand All @@ -43,9 +43,9 @@ auto test_bulk() {

std::vector<int> results(a.size(), 0);

auto b2 = test_std::bulk(test_std::just(a), a.size(), [&](std::size_t index, const std::vector<int>& vec) {
results[index] = vec[index] * b[index];
});
auto b2 = test_std::just(a) | test_std::bulk(a.size(), [&](std::size_t index, const std::vector<int>& vec) {
results[index] = vec[index] * b[index];
});
static_assert(test_std::sender<decltype(b2)>);
auto b2_env = test_std::get_env(b2);
auto b2_completions = test_std::get_completion_signatures(b2, b2_env);
Expand All @@ -65,7 +65,7 @@ auto test_bulk() {
}

auto test_bulk_noexept() {
auto b0 = test_std::bulk(test_std::just(), 1, [](int) noexcept {});
auto b0 = test_std::just() | test_std::bulk(1, [](int) noexcept {});
auto b0_env = test_std::get_env(b0);
auto b0_completions = test_std::get_completion_signatures(b0, b0_env);
static_assert(std::is_same_v<decltype(b0_completions),
Expand All @@ -75,7 +75,7 @@ auto test_bulk_noexept() {

int counter = 0;

auto b1 = test_std::bulk(test_std::just(), 5, [&](int i) noexcept { counter += i; });
auto b1 = test_std::just() | test_std::bulk(5, [&](int i) noexcept { counter += i; });

static_assert(test_std::sender<decltype(b1)>);
auto b1_env = test_std::get_env(b0);
Expand Down