}
template<typename AsyncAction>
-inline auto do_until(AsyncAction action) {
+inline auto repeat(AsyncAction action) {
using errorator_t =
typename ::seastar::futurize_t<std::invoke_result_t<AsyncAction>>::errorator_type;
}
} else {
return std::move(f)._then(
- [action = std::move(action)] (auto &&done) mutable {
- if (done) {
+ [action = std::move(action)] (auto stop) mutable {
+ if (stop == seastar::stop_iteration::yes) {
return errorator_t::template make_ready_future<>();
}
- return ::crimson::do_until(
+ return ::crimson::repeat(
std::move(action));
});
}
AsyncAction action);
template<typename AsyncAction>
- friend inline auto ::crimson::do_until(AsyncAction action);
+ friend inline auto ::crimson::repeat(AsyncAction action);
template <typename Result>
friend class ::seastar::future;
);
} else {
return make_interruptible(
- ::crimson::do_until(
+ ::crimson::repeat(
[action=std::move(action),
interrupt_condition=interrupt_cond<InterruptCond>] {
return call_with_interruption(
);
} else {
return make_interruptible(
- ::crimson::do_until(
+ ::crimson::repeat(
[action=std::move(action),
interrupt_condition=interrupt_cond<InterruptCond>] {
return call_with_interruption(
}
auto retref = std::make_unique<size_t>(0);
auto budget_used = *retref;
- return crimson::do_until(
+ return crimson::repeat(
[=, &cursor, &budget_used, &handler]() mutable
- -> scan_valid_records_ertr::future<bool> {
+ -> scan_valid_records_ertr::future<seastar::stop_iteration> {
return [=, &handler, &cursor, &budget_used] {
if (!cursor.last_valid_header_found) {
return read_validate_record_metadata(cursor.offset, nonce
return scan_valid_records_ertr::now();
}
}).safe_then([=, &cursor, &budget_used, &handler] {
- return crimson::do_until(
+ return crimson::repeat(
[=, &budget_used, &cursor, &handler] {
logger().debug(
"Journal::scan_valid_records: valid record read, processing queue");
* location since it itself cannot yet have been committed
* at its own time of submission. Thus, the most recently
* read record must always fall after cursor.last_committed */
- return scan_valid_records_ertr::make_ready_future<bool>(true);
+ return scan_valid_records_ertr::make_ready_future<
+ seastar::stop_iteration>(seastar::stop_iteration::yes);
}
auto &next = cursor.pending_records.front();
if (next.offset > cursor.last_committed) {
- return scan_valid_records_ertr::make_ready_future<bool>(true);
+ return scan_valid_records_ertr::make_ready_future<
+ seastar::stop_iteration>(seastar::stop_iteration::yes);
}
budget_used +=
next.header.dlength + next.header.mdlength;
next.mdbuffer
).safe_then([&cursor] {
cursor.pending_records.pop_front();
- return scan_valid_records_ertr::make_ready_future<bool>(false);
+ return scan_valid_records_ertr::make_ready_future<
+ seastar::stop_iteration>(seastar::stop_iteration::no);
});
});
});
});
}
}().safe_then([=, &budget_used, &cursor] {
- return scan_valid_records_ertr::make_ready_future<bool>(
- cursor.is_complete() || budget_used >= budget);
+ if (cursor.is_complete() || budget_used >= budget) {
+ return seastar::stop_iteration::yes;
+ } else {
+ return seastar::stop_iteration::no;
+ }
});
}).safe_then([retref=std::move(retref)]() mutable -> scan_valid_records_ret {
return scan_valid_records_ret(
begin,
L_ADDR_NULL,
[this, c, min_addr, len, end=end](auto &i, auto &ret) {
- return crimson::do_until([=, &i, &ret]() -> find_hole_ertr::future<bool> {
+ return crimson::repeat([=, &i, &ret]()
+ -> find_hole_ertr::future<seastar::stop_iteration> {
if (i == end) {
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
return get_lba_btree_extent(
c,
}).safe_then([&i, &ret](auto addr) mutable {
if (addr == L_ADDR_NULL) {
++i;
- return false;
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::no);
} else {
ret = addr;
- return true;
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
});
}).safe_then([&ret, ref=LBANodeRef(this)] {
[=, &start](auto &biter, auto &eiter, auto &ret) {
auto &complete = std::get<0>(ret);
auto &result = std::get<1>(ret);
- return crimson::do_until(
- [&, config, oc, this]() -> list_ertr::future<bool> {
+ return crimson::repeat(
+ [&, config, oc, this]() -> list_ertr::future<seastar::stop_iteration> {
if (biter == eiter || result.size() == config.max_result_size) {
complete = biter == eiter;
- return list_ertr::make_ready_future<bool>(true);
+ return list_ertr::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
auto laddr = biter->get_val();
return omap_load_extent(
result.merge(std::move(child_result));
++biter;
assert(child_complete || result.size() == config.max_result_size);
- return list_ertr::make_ready_future<bool>(false);
+ return list_ertr::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::no);
});
});
}).safe_then([&ret, ref = OMapNodeRef(this)] {
std::move(cursor),
list_onodes_bare_ret(),
[this, &trans, end] (auto& to_list, auto& current_cursor, auto& ret) {
- return crimson::do_until(
+ return crimson::repeat(
[this, &trans, end, &to_list, ¤t_cursor, &ret] () mutable
- -> eagain_future<bool> {
+ -> eagain_future<seastar::stop_iteration> {
if (current_cursor.is_end() ||
current_cursor.get_ghobj() >= end) {
std::get<1>(ret) = end;
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
if (to_list == 0) {
std::get<1>(ret) = current_cursor.get_ghobj();
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
std::get<0>(ret).emplace_back(current_cursor.get_ghobj());
return tree.get_next(trans, current_cursor
// accelerate tree lookup.
--to_list;
current_cursor = next_cursor;
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
}).safe_then([&ret] () mutable {
return seastar::make_ready_future<list_onodes_bare_ret>(
[this, this_ref, c, &stats](auto& pos, auto& p_child_addr) {
pos = search_position_t::begin();
impl->get_slot(pos, nullptr, &p_child_addr);
- return crimson::do_until(
- [this, this_ref, c, &stats, &pos, &p_child_addr]() -> eagain_future<bool> {
+ return crimson::repeat(
+ [this, this_ref, c, &stats, &pos, &p_child_addr]()
+ -> eagain_future<seastar::stop_iteration> {
return get_or_track_child(c, pos, p_child_addr->value
).safe_then([c, &stats](auto child) {
return child->do_get_tree_stats(c, stats);
}).safe_then([this, this_ref, &pos, &p_child_addr] {
if (pos.is_end()) {
- return seastar::make_ready_future<bool>(true);
+ return seastar::stop_iteration::yes;
} else {
impl->get_next_slot(pos, nullptr, &p_child_addr);
if (pos.is_end()) {
if (impl->is_level_tail()) {
p_child_addr = impl->get_tail_value();
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
} else {
- return seastar::make_ready_future<bool>(true);
+ return seastar::stop_iteration::yes;
}
} else {
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
}
}
});
auto cursors = seastar::make_lw_shared<std::vector<BtreeCursor>>();
logger().warn("start inserting {} kvs ...", kvs.size());
auto start_time = mono_clock::now();
- return crimson::do_until([&t, this, cursors, ref_kv_iter,
- start_time]() -> eagain_future<bool> {
+ return crimson::repeat([&t, this, cursors, ref_kv_iter,
+ start_time]()
+ -> eagain_future<seastar::stop_iteration> {
if (*ref_kv_iter == kvs.random_end()) {
std::chrono::duration<double> duration = mono_clock::now() - start_time;
logger().warn("Insert done! {}s", duration.count());
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
} else {
return insert_one(t, *ref_kv_iter
).safe_then([cursors, ref_kv_iter] (auto cursor) {
cursors->emplace_back(cursor);
}
++(*ref_kv_iter);
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
}
}).safe_then([&t, this, cursors, ref_kv_iter] {
return seastar::do_with(
cursors->begin(),
[&t, this, cursors, ref_kv_iter] (auto& c_iter) {
- return crimson::do_until(
- [&t, this, &c_iter, cursors, ref_kv_iter] () -> eagain_future<bool> {
+ return crimson::repeat(
+ [&t, this, &c_iter, cursors, ref_kv_iter] ()
+ -> eagain_future<seastar::stop_iteration> {
if (*ref_kv_iter == kvs.random_end()) {
logger().info("Verify done!");
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
assert(c_iter != cursors->end());
auto p_kv = **ref_kv_iter;
validate_cursor_from_item(p_kv->key, p_kv->value, *c_iter);
++(*ref_kv_iter);
++c_iter;
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
});
});
logger().info("Tracking cursors before erase ...");
*ref_kv_iter = kvs.begin();
auto start_time = mono_clock::now();
- return crimson::do_until(
- [&t, this, cursors, ref_kv_iter, start_time] () -> eagain_future<bool> {
+ return crimson::repeat(
+ [&t, this, cursors, ref_kv_iter, start_time] ()
+ -> eagain_future<seastar::stop_iteration> {
if (*ref_kv_iter == kvs.end()) {
std::chrono::duration<double> duration = mono_clock::now() - start_time;
logger().info("Track done! {}s", duration.count());
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
auto p_kv = **ref_kv_iter;
return tree->find(t, p_kv->key).safe_then([this, cursors, ref_kv_iter](auto cursor) {
validate_cursor_from_item(p_kv->key, p_kv->value, cursor);
cursors->emplace(p_kv->key, cursor);
++(*ref_kv_iter);
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
});
} else {
logger().warn("start erasing {}/{} kvs ...",
erase_end - kvs.random_begin(), kvs.size());
auto start_time = mono_clock::now();
- return crimson::do_until([&t, this, ref_kv_iter,
- start_time, erase_end] () -> eagain_future<bool> {
+ return crimson::repeat([&t, this, ref_kv_iter,
+ start_time, erase_end] ()
+ -> eagain_future<seastar::stop_iteration> {
if (*ref_kv_iter == erase_end) {
std::chrono::duration<double> duration = mono_clock::now() - start_time;
logger().warn("Erase done! {}s", duration.count());
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
} else {
return erase_one(t, *ref_kv_iter
).safe_then([ref_kv_iter] {
++(*ref_kv_iter);
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
}
});
interval_set<blk_id_t>(),
bp,
[&, this] (auto &allocated, auto &addr, auto &alloc_extent, auto &bp) mutable {
- return crimson::do_until(
+ return crimson::repeat(
[&, this] () mutable {
return device->read(
addr,
logger().debug("find_free_list: allocated: {} alloc_extent {}",
allocated, alloc_extent);
if (((uint64_t)size)/super.block_size == allocated) {
- return find_block_ertr::make_ready_future<bool>(true);
+ return seastar::stop_iteration::yes;
} else if (addr >= super.start_data_area) {
alloc_extent.clear();
- return find_block_ertr::make_ready_future<bool>(true);
+ return seastar::stop_iteration::yes;
}
- return find_block_ertr::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
}).safe_then([&allocated, &alloc_extent, size, this] () {
logger().debug(" allocated: {} size {} ",
auto bp = bufferptr(ceph::buffer::create_page_aligned(super.block_size));
return seastar::do_with(uint64_t(super.start_alloc_area), uint64_t(0), bp,
[&, this] (auto &addr, auto &free_blocks, auto &bp) mutable {
- return crimson::do_until([&, this] () mutable {
+ return crimson::repeat([&, this] () mutable {
return device->read(addr,bp).safe_then(
[&bp, &addr, &free_blocks, this]() mutable {
logger().debug("verify_bitmap_blocks: addr {}", addr);
}
addr += super.block_size;
if (addr >= super.start_data_area) {
- return find_block_ertr::make_ready_future<bool>(true);
+ return seastar::stop_iteration::yes;
}
- return find_block_ertr::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
}).safe_then([&free_blocks, this] () {
logger().debug(" free_blocks: {} ", free_blocks);
*ctx.transaction, ctx.iter.get_objects()
).safe_then([this, &ctx](auto &&read_onodes) {
ctx.onodes = std::move(read_onodes);
- return crimson::do_until(
- [this, &ctx]() -> tm_ertr::future<bool> {
+ return crimson::repeat(
+ [this, &ctx]() -> tm_ertr::future<seastar::stop_iteration> {
if (ctx.iter.have_op()) {
return _do_transaction_step(
ctx, ctx.ch, ctx.onodes, ctx.iter
).safe_then([] {
- return seastar::make_ready_future<bool>(false);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::no);
});
} else {
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
};
});
}).safe_then([this, &ctx] {
return seastar::do_with(
std::forward<F>(f),
[FNAME](auto &f) {
- return crimson::do_until(
+ return crimson::repeat(
[FNAME, &f] {
return std::invoke(f
).safe_then([] {
- return true;
+ return seastar::stop_iteration::yes;
}).handle_error(
[FNAME](const crimson::ct_error::eagain &e) {
DEBUG("hit eagain, restarting");
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
},
crimson::ct_error::pass_further_all{}
);
).safe_then([this](auto initial_child) {
// split
splitable_nodes.insert(initial_child);
- return crimson::do_until([this] () -> eagain_future<bool> {
+ return crimson::repeat([this] ()
+ -> eagain_future<seastar::stop_iteration> {
if (splitable_nodes.empty()) {
- return seastar::make_ready_future<bool>(true);
+ return seastar::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
auto index = rd() % splitable_nodes.size();
auto iter = splitable_nodes.begin();
Ref<DummyChild> child = *iter;
return child->populate_split(get_context(), splitable_nodes
).safe_then([] {
- return seastar::make_ready_future<bool>(false);
+ return seastar::stop_iteration::no;
});
});
}).safe_then([this] {
struct errorator_test_t : public seastar_test_suite_t {
using ertr = crimson::errorator<crimson::ct_error::invarg>;
ertr::future<> test_do_until() {
- return crimson::do_until([i=0]() mutable {
+ return crimson::repeat([i=0]() mutable {
if (i < 5) {
++i;
- return ertr::make_ready_future<bool>(false);
+ return ertr::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::no);
} else {
- return ertr::make_ready_future<bool>(true);
+ return ertr::make_ready_future<seastar::stop_iteration>(
+ seastar::stop_iteration::yes);
}
});
}