Commit d1f11390 authored by Dominik Charousset's avatar Dominik Charousset

Fix sign and conversion warnings

parent e75871fc
...@@ -55,12 +55,12 @@ public: ...@@ -55,12 +55,12 @@ public:
} }
/// @pre `n <= buf_.size()` /// @pre `n <= buf_.size()`
static chunk_type get_chunk(buffer_type& buf, long n) { static chunk_type get_chunk(buffer_type& buf, size_t n) {
CAF_LOG_TRACE(CAF_ARG(buf) << CAF_ARG(n)); CAF_LOG_TRACE(CAF_ARG(buf) << CAF_ARG(n));
chunk_type xs; chunk_type xs;
if (!buf.empty() && n > 0) { if (!buf.empty() && n > 0) {
xs.reserve(std::min(static_cast<size_t>(n), buf.size())); xs.reserve(std::min(n, buf.size()));
if (static_cast<size_t>(n) < buf.size()) { if (n < buf.size()) {
auto first = buf.begin(); auto first = buf.begin();
auto last = first + static_cast<ptrdiff_t>(n); auto last = first + static_cast<ptrdiff_t>(n);
std::move(first, last, std::back_inserter(xs)); std::move(first, last, std::back_inserter(xs));
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
return xs; return xs;
} }
chunk_type get_chunk(long n) { chunk_type get_chunk(size_t n) {
return get_chunk(buf_, n); return get_chunk(buf_, n);
} }
......
...@@ -70,24 +70,24 @@ public: ...@@ -70,24 +70,24 @@ public:
template <class F> template <class F>
void update(time_point now, F& consumer) { void update(time_point now, F& consumer) {
CAF_ASSERT(interval_.count() != 0); CAF_ASSERT(interval_.count() != 0);
auto diff = now - start_; auto d = now - start_;
auto current_tick_id = diff.count() / interval_.count(); auto current_tick_id = static_cast<size_t>(d.count() / interval_.count());
while (last_tick_id_ < current_tick_id) while (last_tick_id_ < current_tick_id)
consumer(++last_tick_id_); consumer(++last_tick_id_);
} }
/// Advances time by `t` and returns all triggered periods as bitmask. /// Advances time by `t` and returns all triggered periods as bitmask.
long timeouts(time_point t, std::initializer_list<long> periods); size_t timeouts(time_point t, std::initializer_list<size_t> periods);
/// Returns the next time point after `t` that would trigger any of the tick /// Returns the next time point after `t` that would trigger any of the tick
/// periods, i.e., returns the next time where any of the tick periods /// periods, i.e., returns the next time where any of the tick periods
/// triggers `tick id % period == 0`. /// triggers `tick id % period == 0`.
time_point next_timeout(time_point t, std::initializer_list<long> periods); time_point next_timeout(time_point t, std::initializer_list<size_t> periods);
private: private:
time_point start_; time_point start_;
duration_type interval_; duration_type interval_;
long last_tick_id_; size_t last_tick_id_;
}; };
} // namespace detail } // namespace detail
......
...@@ -72,14 +72,15 @@ public: ...@@ -72,14 +72,15 @@ public:
/// Sends a `downstream_msg::batch` on this path. Decrements `open_credit` by /// Sends a `downstream_msg::batch` on this path. Decrements `open_credit` by
/// `xs_size` and increments `next_batch_id` by 1. /// `xs_size` and increments `next_batch_id` by 1.
void emit_batch(local_actor* self, long xs_size, message xs); void emit_batch(local_actor* self, int32_t xs_size, message xs);
template <class Iterator> template <class Iterator>
Iterator emit_batches_impl(local_actor* self, Iterator i, Iterator e, Iterator emit_batches_impl(local_actor* self, Iterator i, Iterator e,
bool force_underfull) { bool force_underfull) {
CAF_LOG_TRACE(CAF_ARG(force_underfull)); CAF_LOG_TRACE(CAF_ARG(force_underfull));
using type = detail::decay_t<decltype(*i)>; using type = detail::decay_t<decltype(*i)>;
while (std::distance(i, e) >= static_cast<ptrdiff_t>(desired_batch_size)) { // Signed Desired Batch Size.
while (std::distance(i, e) >= desired_batch_size) {
std::vector<type> tmp{std::make_move_iterator(i), std::vector<type> tmp{std::make_move_iterator(i),
std::make_move_iterator(i + desired_batch_size)}; std::make_move_iterator(i + desired_batch_size)};
emit_batch(self, desired_batch_size, make_message(std::move(tmp))); emit_batch(self, desired_batch_size, make_message(std::move(tmp)));
...@@ -88,7 +89,7 @@ public: ...@@ -88,7 +89,7 @@ public:
if (i != e && force_underfull) { if (i != e && force_underfull) {
std::vector<type> tmp{std::make_move_iterator(i), std::vector<type> tmp{std::make_move_iterator(i),
std::make_move_iterator(e)}; std::make_move_iterator(e)};
auto tmp_size = static_cast<long>(tmp.size()); auto tmp_size = static_cast<int32_t>(tmp.size());
emit_batch(self, tmp_size, make_message(std::move(tmp))); emit_batch(self, tmp_size, make_message(std::move(tmp)));
return e; return e;
} }
...@@ -104,8 +105,10 @@ public: ...@@ -104,8 +105,10 @@ public:
if (pending()) if (pending())
return; return;
CAF_ASSERT(desired_batch_size > 0); CAF_ASSERT(desired_batch_size > 0);
CAF_ASSERT(cache.size() < std::numeric_limits<int32_t>::max());
auto first = cache.begin(); auto first = cache.begin();
auto last = first + std::min(open_credit, static_cast<long>(cache.size())); auto last = first + std::min(open_credit,
static_cast<int32_t>(cache.size()));
if (first == last) if (first == last)
return; return;
auto i = emit_batches_impl(self, first, last, force_underfull); auto i = emit_batches_impl(self, first, last, force_underfull);
...@@ -147,10 +150,10 @@ public: ...@@ -147,10 +150,10 @@ public:
int64_t next_batch_id; int64_t next_batch_id;
/// Currently available credit on this path. /// Currently available credit on this path.
long open_credit; int32_t open_credit;
/// Ideal batch size. Configured by the sink. /// Ideal batch size. Configured by the sink.
uint64_t desired_batch_size; int32_t desired_batch_size;
/// ID of the first unacknowledged batch. Note that CAF uses accumulative /// ID of the first unacknowledged batch. Note that CAF uses accumulative
/// ACKs, i.e., receiving an ACK with a higher ID is not an error. /// ACKs, i.e., receiving an ACK with a higher ID is not an error.
......
...@@ -885,10 +885,10 @@ protected: ...@@ -885,10 +885,10 @@ protected:
detail::tick_emitter stream_ticks_; detail::tick_emitter stream_ticks_;
/// Number of ticks per batch delay. /// Number of ticks per batch delay.
long max_batch_delay_ticks_; size_t max_batch_delay_ticks_;
/// Number of ticks of each credit round. /// Number of ticks of each credit round.
long credit_round_ticks_; size_t credit_round_ticks_;
/// Pointer to a private thread object associated with a detached actor. /// Pointer to a private thread object associated with a detached actor.
detail::private_thread* private_thread_; detail::private_thread* private_thread_;
......
...@@ -94,7 +94,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) { ...@@ -94,7 +94,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) {
// actor lives in its own thread // actor lives in its own thread
ptr->home_system->thread_started(); ptr->home_system->thread_started();
auto this_ptr = ptr->get(); auto this_ptr = ptr->get();
CAF_ASSERT(dynamic_cast<blocking_actor*>(this_ptr) != 0); CAF_ASSERT(dynamic_cast<blocking_actor*>(this_ptr) != nullptr);
auto self = static_cast<blocking_actor*>(this_ptr); auto self = static_cast<blocking_actor*>(this_ptr);
CAF_SET_LOGGER_SYS(ptr->home_system); CAF_SET_LOGGER_SYS(ptr->home_system);
CAF_PUSH_AID_FROM_PTR(self); CAF_PUSH_AID_FROM_PTR(self);
......
...@@ -65,7 +65,7 @@ bool downstream_messages::enabled(const nested_queue_type& q) noexcept { ...@@ -65,7 +65,7 @@ bool downstream_messages::enabled(const nested_queue_type& q) noexcept {
auto downstream_messages::quantum(const nested_queue_type& q, auto downstream_messages::quantum(const nested_queue_type& q,
deficit_type x) noexcept -> deficit_type { deficit_type x) noexcept -> deficit_type {
// TODO: adjust quantum based on the stream priority // TODO: adjust quantum based on the stream priority
return x * q.policy().handler->desired_batch_size; return x * static_cast<deficit_type>(q.policy().handler->desired_batch_size);
} }
} // namespace policy } // namespace policy
......
...@@ -56,7 +56,7 @@ void outbound_path::emit_open(local_actor* self, stream_slot slot, ...@@ -56,7 +56,7 @@ void outbound_path::emit_open(local_actor* self, stream_slot slot,
nullptr, prio}); nullptr, prio});
} }
void outbound_path::emit_batch(local_actor* self, long xs_size, message xs) { void outbound_path::emit_batch(local_actor* self, int32_t xs_size, message xs) {
CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(xs_size) << CAF_ARG(xs)); CAF_LOG_TRACE(CAF_ARG(slots) << CAF_ARG(xs_size) << CAF_ARG(xs));
CAF_ASSERT(xs_size > 0); CAF_ASSERT(xs_size > 0);
CAF_ASSERT(xs_size <= std::numeric_limits<int32_t>::max()); CAF_ASSERT(xs_size <= std::numeric_limits<int32_t>::max());
......
...@@ -1099,13 +1099,14 @@ scheduled_actor::advance_streams(actor_clock::time_point now) { ...@@ -1099,13 +1099,14 @@ scheduled_actor::advance_streams(actor_clock::time_point now) {
// Fill up credit on each input path. // Fill up credit on each input path.
if ((bitmask & 0x02) != 0) { if ((bitmask & 0x02) != 0) {
auto cycle = stream_ticks_.interval(); auto cycle = stream_ticks_.interval();
cycle *= credit_round_ticks_; cycle *= static_cast<decltype(cycle)>credit_round_ticks_;
auto bc_us = home_system().config().streaming_desired_batch_complexity_us; auto bc_us = home_system().config().streaming_desired_batch_complexity_us;
auto bc = std::chrono::microseconds(bc_us); auto bc = std::chrono::microseconds(bc_us);
auto& qs = get<2>(mailbox_.queue().queues()).queues(); auto& qs = get<2>(mailbox_.queue().queues()).queues();
for (auto& kvp : qs) { for (auto& kvp : qs) {
auto inptr = kvp.second.policy().handler.get(); auto inptr = kvp.second.policy().handler.get();
inptr->emit_ack_batch(this, kvp.second.total_task_size(), cycle, bc); auto bs = static_cast<int32_t>(kvp.second.total_task_size());
inptr->emit_ack_batch(this, bs, cycle, bc);
} }
} }
return stream_ticks_.next_timeout(now, {max_batch_delay_ticks_, return stream_ticks_.next_timeout(now, {max_batch_delay_ticks_,
......
...@@ -54,12 +54,12 @@ void tick_emitter::interval(duration_type x) { ...@@ -54,12 +54,12 @@ void tick_emitter::interval(duration_type x) {
interval_ = x; interval_ = x;
} }
long tick_emitter::timeouts(time_point now, size_t tick_emitter::timeouts(time_point now,
std::initializer_list<long> periods) { std::initializer_list<size_t> periods) {
CAF_LOG_TRACE(CAF_ARG(now) << CAF_ARG(periods)); CAF_LOG_TRACE(CAF_ARG(now) << CAF_ARG(periods));
long result = 0; size_t result = 0;
auto f = [&](long tick) { auto f = [&](size_t tick) {
long n = 0; size_t n = 0;
for (auto p : periods) { for (auto p : periods) {
if (tick % p == 0) if (tick % p == 0)
result |= 1l << n; result |= 1l << n;
...@@ -71,16 +71,17 @@ long tick_emitter::timeouts(time_point now, ...@@ -71,16 +71,17 @@ long tick_emitter::timeouts(time_point now,
} }
tick_emitter::time_point tick_emitter::time_point
tick_emitter::next_timeout(time_point t, std::initializer_list<long> periods) { tick_emitter::next_timeout(time_point t,
std::initializer_list<size_t> periods) {
CAF_ASSERT(interval_.count() != 0); CAF_ASSERT(interval_.count() != 0);
auto is_trigger = [&](long tick_id) { auto is_trigger = [&](size_t tick_id) {
for (auto period : periods) for (auto period : periods)
if (tick_id % period == 0) if (tick_id % period == 0)
return true; return true;
return false; return false;
}; };
auto diff = t - start_; auto diff = t - start_;
auto this_tick = diff.count() / interval_.count(); auto this_tick = static_cast<size_t>(diff.count() / interval_.count());
auto tick_id = this_tick + 1; auto tick_id = this_tick + 1;
while (!is_trigger(tick_id)) while (!is_trigger(tick_id))
++tick_id; ++tick_id;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define CAF_SUITE broadcast_downstream_manager #define CAF_SUITE broadcast_downstream_manager
#include <cstdint>
#include <memory> #include <memory>
#include "caf/actor_system.hpp" #include "caf/actor_system.hpp"
...@@ -85,7 +86,7 @@ public: ...@@ -85,7 +86,7 @@ public:
// nop // nop
} }
void add_path_to(entity& x, int desired_batch_size) { void add_path_to(entity& x, int32_t desired_batch_size) {
auto ptr = bs.add_path(next_slot++, x.ctrl()); auto ptr = bs.add_path(next_slot++, x.ctrl());
CAF_REQUIRE(ptr != nullptr); CAF_REQUIRE(ptr != nullptr);
ptr->desired_batch_size = desired_batch_size; ptr->desired_batch_size = desired_batch_size;
...@@ -93,7 +94,7 @@ public: ...@@ -93,7 +94,7 @@ public:
paths.emplace_back(ptr); paths.emplace_back(ptr);
} }
size_t credit_for(entity& x) { long credit_for(entity& x) {
auto pred = [&](outbound_path* ptr) { auto pred = [&](outbound_path* ptr) {
return ptr->hdl == &x; return ptr->hdl == &x;
}; };
...@@ -198,7 +199,7 @@ struct fixture { ...@@ -198,7 +199,7 @@ struct fixture {
batch_type make_batch(int first, int last) { batch_type make_batch(int first, int last) {
batch_type result; batch_type result;
result.resize((last + 1) - first); result.resize(static_cast<size_t>((last + 1) - first));
std::iota(result.begin(), result.end(), first); std::iota(result.begin(), result.end(), first);
return result; return result;
} }
...@@ -298,7 +299,7 @@ receive_checker<F> operator<<(receive_checker<F> xs, not_empty_t) { ...@@ -298,7 +299,7 @@ receive_checker<F> operator<<(receive_checker<F> xs, not_empty_t) {
#define FOR \ #define FOR \
struct CONCAT(for_helper_, __LINE__) { \ struct CONCAT(for_helper_, __LINE__) { \
entity& who; \ entity& who; \
size_t amount; \ long amount; \
void operator<<(entity& x) const { \ void operator<<(entity& x) const { \
CAF_CHECK_EQUAL(who.credit_for(x), amount); \ CAF_CHECK_EQUAL(who.credit_for(x), amount); \
} \ } \
......
...@@ -144,7 +144,7 @@ using fixture = test_coordinator_fixture<>; ...@@ -144,7 +144,7 @@ using fixture = test_coordinator_fixture<>;
CAF_TEST_FIXTURE_SCOPE(local_streaming_tests, fixture) CAF_TEST_FIXTURE_SCOPE(local_streaming_tests, fixture)
CAF_TEST(depth_3_pipeline_with_fork) { CAF_TEST(depth_3_pipeline_with_fork) {
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto stg = sys.spawn(stream_multiplexer); auto stg = sys.spawn(stream_multiplexer);
auto snk1 = sys.spawn(sum_up); auto snk1 = sys.spawn(sum_up);
auto snk2 = sys.spawn(sum_up); auto snk2 = sys.spawn(sum_up);
...@@ -168,8 +168,8 @@ CAF_TEST(depth_3_pipeline_with_fork) { ...@@ -168,8 +168,8 @@ CAF_TEST(depth_3_pipeline_with_fork) {
} }
CAF_TEST(depth_3_pipeline_with_join) { CAF_TEST(depth_3_pipeline_with_join) {
auto src1 = sys.spawn(file_reader, 50); auto src1 = sys.spawn(file_reader, 50u);
auto src2 = sys.spawn(file_reader, 50); auto src2 = sys.spawn(file_reader, 50u);
auto stg = sys.spawn(stream_multiplexer); auto stg = sys.spawn(stream_multiplexer);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
auto& st = deref<stream_multiplexer_actor>(stg).state; auto& st = deref<stream_multiplexer_actor>(stg).state;
......
...@@ -261,8 +261,8 @@ using fixture = test_coordinator_fixture<>; ...@@ -261,8 +261,8 @@ using fixture = test_coordinator_fixture<>;
CAF_TEST_FIXTURE_SCOPE(fused_streaming_tests, fixture) CAF_TEST_FIXTURE_SCOPE(fused_streaming_tests, fixture)
CAF_TEST(depth_3_pipeline_with_fork) { CAF_TEST(depth_3_pipeline_with_fork) {
auto src1 = sys.spawn(int_file_reader, 50); auto src1 = sys.spawn(int_file_reader, 50u);
auto src2 = sys.spawn(string_file_reader, 50); auto src2 = sys.spawn(string_file_reader, 50u);
auto stg = sys.spawn(stream_multiplexer); auto stg = sys.spawn(stream_multiplexer);
auto snk1 = sys.spawn(sum_up); auto snk1 = sys.spawn(sum_up);
auto snk2 = sys.spawn(collect); auto snk2 = sys.spawn(collect);
......
...@@ -129,10 +129,10 @@ struct dmsg { ...@@ -129,10 +129,10 @@ struct dmsg {
struct umsg { struct umsg {
struct ack_handshake { struct ack_handshake {
long credit; int32_t credit;
}; };
struct ack_batch { struct ack_batch {
long credit; int32_t credit;
}; };
struct drop { struct drop {
// nop // nop
......
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
using duration_type = time_point::duration; using duration_type = time_point::duration;
/// The type of a single tick. /// The type of a single tick.
using tick_type = long; using tick_type = size_t;
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
...@@ -186,8 +186,10 @@ public: ...@@ -186,8 +186,10 @@ public:
: *global_time) { : *global_time) {
auto cycle = detail::gcd(credit_interval.count(), auto cycle = detail::gcd(credit_interval.count(),
force_batches_interval.count()); force_batches_interval.count());
ticks_per_force_batches_interval = force_batches_interval.count() / cycle; ticks_per_force_batches_interval =
ticks_per_credit_interval = credit_interval.count() / cycle; static_cast<size_t>(force_batches_interval.count() / cycle);
ticks_per_credit_interval =
static_cast<size_t>(credit_interval.count() / cycle);
tick_emitter_.interval(duration_type{cycle}); tick_emitter_.interval(duration_type{cycle});
} }
...@@ -342,8 +344,8 @@ public: ...@@ -342,8 +344,8 @@ public:
auto& qs = get<2>(mbox.queues()).queues(); auto& qs = get<2>(mbox.queues()).queues();
for (auto& kvp : qs) { for (auto& kvp : qs) {
auto inptr = kvp.second.policy().handler.get(); auto inptr = kvp.second.policy().handler.get();
inptr->emit_ack_batch(this, kvp.second.total_task_size(), cycle, auto bs = static_cast<int32_t>(kvp.second.total_task_size());
desired_batch_complexity); inptr->emit_ack_batch(this, bs, cycle, desired_batch_complexity);
} }
} }
}; };
...@@ -604,7 +606,9 @@ struct fixture { ...@@ -604,7 +606,9 @@ struct fixture {
}; };
vector<int> make_iota(int first, int last) { vector<int> make_iota(int first, int last) {
vector<int> result(last - first); CAF_ASSERT(first < last);
vector<int> result;
result.resize(static_cast<size_t>(last - first));
std::iota(result.begin(), result.end(), first); std::iota(result.begin(), result.end(), first);
return result; return result;
} }
......
...@@ -220,7 +220,7 @@ using fixture = test_coordinator_fixture<>; ...@@ -220,7 +220,7 @@ using fixture = test_coordinator_fixture<>;
CAF_TEST_FIXTURE_SCOPE(local_streaming_tests, fixture) CAF_TEST_FIXTURE_SCOPE(local_streaming_tests, fixture)
CAF_TEST(depth_2_pipeline_50_items) { CAF_TEST(depth_2_pipeline_50_items) {
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -241,7 +241,7 @@ CAF_TEST(depth_2_pipeline_50_items) { ...@@ -241,7 +241,7 @@ CAF_TEST(depth_2_pipeline_50_items) {
} }
CAF_TEST(depth_2_pipeline_setup2_50_items) { CAF_TEST(depth_2_pipeline_setup2_50_items) {
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -262,7 +262,7 @@ CAF_TEST(depth_2_pipeline_setup2_50_items) { ...@@ -262,7 +262,7 @@ CAF_TEST(depth_2_pipeline_setup2_50_items) {
} }
CAF_TEST(delayed_depth_2_pipeline_50_items) { CAF_TEST(delayed_depth_2_pipeline_50_items) {
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto snk = sys.spawn(delayed_sum_up); auto snk = sys.spawn(delayed_sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -289,7 +289,7 @@ CAF_TEST(delayed_depth_2_pipeline_50_items) { ...@@ -289,7 +289,7 @@ CAF_TEST(delayed_depth_2_pipeline_50_items) {
} }
CAF_TEST(depth_2_pipeline_500_items) { CAF_TEST(depth_2_pipeline_500_items) {
auto src = sys.spawn(file_reader, 500); auto src = sys.spawn(file_reader, 500u);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -318,7 +318,7 @@ CAF_TEST(depth_2_pipeline_500_items) { ...@@ -318,7 +318,7 @@ CAF_TEST(depth_2_pipeline_500_items) {
CAF_TEST(depth_2_pipeline_error_during_handshake) { CAF_TEST(depth_2_pipeline_error_during_handshake) {
CAF_MESSAGE("streams must abort if a sink fails to initialize its state"); CAF_MESSAGE("streams must abort if a sink fails to initialize its state");
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto snk = sys.spawn(broken_sink); auto snk = sys.spawn(broken_sink);
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
self->send(snk * src, "numbers.txt"); self->send(snk * src, "numbers.txt");
...@@ -330,7 +330,7 @@ CAF_TEST(depth_2_pipeline_error_during_handshake) { ...@@ -330,7 +330,7 @@ CAF_TEST(depth_2_pipeline_error_during_handshake) {
CAF_TEST(depth_2_pipeline_error_at_source) { CAF_TEST(depth_2_pipeline_error_at_source) {
CAF_MESSAGE("streams must abort if a source fails at runtime"); CAF_MESSAGE("streams must abort if a source fails at runtime");
auto src = sys.spawn(file_reader, 500); auto src = sys.spawn(file_reader, 500u);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -348,7 +348,7 @@ CAF_TEST(depth_2_pipeline_error_at_source) { ...@@ -348,7 +348,7 @@ CAF_TEST(depth_2_pipeline_error_at_source) {
CAF_TEST(depth_2_pipelin_error_at_sink) { CAF_TEST(depth_2_pipelin_error_at_sink) {
CAF_MESSAGE("streams must abort if a sink fails at runtime"); CAF_MESSAGE("streams must abort if a sink fails at runtime");
auto src = sys.spawn(file_reader, 500); auto src = sys.spawn(file_reader, 500u);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk)); CAF_MESSAGE(CAF_ARG(self) << CAF_ARG(src) << CAF_ARG(snk));
CAF_MESSAGE("initiate stream handshake"); CAF_MESSAGE("initiate stream handshake");
...@@ -364,7 +364,7 @@ CAF_TEST(depth_2_pipelin_error_at_sink) { ...@@ -364,7 +364,7 @@ CAF_TEST(depth_2_pipelin_error_at_sink) {
} }
CAF_TEST(depth_3_pipeline_50_items) { CAF_TEST(depth_3_pipeline_50_items) {
auto src = sys.spawn(file_reader, 50); auto src = sys.spawn(file_reader, 50u);
auto stg = sys.spawn(filter); auto stg = sys.spawn(filter);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
auto next_cycle = [&] { auto next_cycle = [&] {
...@@ -399,7 +399,7 @@ CAF_TEST(depth_3_pipeline_50_items) { ...@@ -399,7 +399,7 @@ CAF_TEST(depth_3_pipeline_50_items) {
} }
CAF_TEST(depth_4_pipeline_500_items) { CAF_TEST(depth_4_pipeline_500_items) {
auto src = sys.spawn(file_reader, 500); auto src = sys.spawn(file_reader, 500u);
auto stg1 = sys.spawn(filter); auto stg1 = sys.spawn(filter);
auto stg2 = sys.spawn(doubler); auto stg2 = sys.spawn(doubler);
auto snk = sys.spawn(sum_up); auto snk = sys.spawn(sum_up);
......
...@@ -72,14 +72,15 @@ CAF_TEST(ticks) { ...@@ -72,14 +72,15 @@ CAF_TEST(ticks) {
auto cycle = detail::gcd(credit_interval.count(), auto cycle = detail::gcd(credit_interval.count(),
force_batch_interval.count()); force_batch_interval.count());
CAF_CHECK_EQUAL(cycle, 50); CAF_CHECK_EQUAL(cycle, 50);
auto force_batch_frequency = force_batch_interval.count() / cycle; auto force_batch_frequency =
auto credit_frequency = credit_interval.count() / cycle; static_cast<size_t>(force_batch_interval.count() / cycle);
auto credit_frequency = static_cast<size_t>(credit_interval.count() / cycle);
detail::tick_emitter tctrl{time_point{timespan{100}}}; detail::tick_emitter tctrl{time_point{timespan{100}}};
tctrl.interval(timespan{cycle}); tctrl.interval(timespan{cycle});
vector<long> ticks; vector<size_t> ticks;
int force_batch_triggers = 0; size_t force_batch_triggers = 0;
int credit_triggers = 0; size_t credit_triggers = 0;
auto f = [&](long tick_id) { auto f = [&](size_t tick_id) {
ticks.push_back(tick_id); ticks.push_back(tick_id);
if (tick_id % force_batch_frequency == 0) if (tick_id % force_batch_frequency == 0)
++force_batch_triggers; ++force_batch_triggers;
...@@ -89,13 +90,13 @@ CAF_TEST(ticks) { ...@@ -89,13 +90,13 @@ CAF_TEST(ticks) {
CAF_MESSAGE("trigger 4 ticks"); CAF_MESSAGE("trigger 4 ticks");
tctrl.update(time_point{timespan{300}}, f); tctrl.update(time_point{timespan{300}}, f);
CAF_CHECK_EQUAL(deep_to_string(ticks), "[1, 2, 3, 4]"); CAF_CHECK_EQUAL(deep_to_string(ticks), "[1, 2, 3, 4]");
CAF_CHECK_EQUAL(force_batch_triggers, 4); CAF_CHECK_EQUAL(force_batch_triggers, 4lu);
CAF_CHECK_EQUAL(credit_triggers, 1); CAF_CHECK_EQUAL(credit_triggers, 1lu);
CAF_MESSAGE("trigger 3 more ticks"); CAF_MESSAGE("trigger 3 more ticks");
tctrl.update(time_point{timespan{475}}, f); tctrl.update(time_point{timespan{475}}, f);
CAF_CHECK_EQUAL(deep_to_string(ticks), "[1, 2, 3, 4, 5, 6, 7]"); CAF_CHECK_EQUAL(deep_to_string(ticks), "[1, 2, 3, 4, 5, 6, 7]");
CAF_CHECK_EQUAL(force_batch_triggers, 7); CAF_CHECK_EQUAL(force_batch_triggers, 7lu);
CAF_CHECK_EQUAL(credit_triggers, 1); CAF_CHECK_EQUAL(credit_triggers, 1lu);
} }
CAF_TEST(timeouts) { CAF_TEST(timeouts) {
...@@ -107,23 +108,23 @@ CAF_TEST(timeouts) { ...@@ -107,23 +108,23 @@ CAF_TEST(timeouts) {
CAF_MESSAGE("advance until the first 5-tick-period ends"); CAF_MESSAGE("advance until the first 5-tick-period ends");
now += interval * 5; now += interval * 5;
auto bitmask = tctrl.timeouts(now, {5, 7}); auto bitmask = tctrl.timeouts(now, {5, 7});
CAF_CHECK_EQUAL(bitmask, 0x01); CAF_CHECK_EQUAL(bitmask, 0x01u);
CAF_MESSAGE("advance until the first 7-tick-period ends"); CAF_MESSAGE("advance until the first 7-tick-period ends");
now += interval * 2; now += interval * 2;
bitmask = tctrl.timeouts(now, {5, 7}); bitmask = tctrl.timeouts(now, {5, 7});
CAF_CHECK_EQUAL(bitmask, 0x02); CAF_CHECK_EQUAL(bitmask, 0x02u);
CAF_MESSAGE("advance until both tick period ends"); CAF_MESSAGE("advance until both tick period ends");
now += interval * 7; now += interval * 7;
bitmask = tctrl.timeouts(now, {5, 7}); bitmask = tctrl.timeouts(now, {5, 7});
CAF_CHECK_EQUAL(bitmask, 0x03); CAF_CHECK_EQUAL(bitmask, 0x03u);
CAF_MESSAGE("advance until both tick period end multiple times"); CAF_MESSAGE("advance until both tick period end multiple times");
now += interval * 21; now += interval * 21;
bitmask = tctrl.timeouts(now, {5, 7}); bitmask = tctrl.timeouts(now, {5, 7});
CAF_CHECK_EQUAL(bitmask, 0x03); CAF_CHECK_EQUAL(bitmask, 0x03u);
CAF_MESSAGE("advance without any timeout"); CAF_MESSAGE("advance without any timeout");
now += interval * 1; now += interval * 1;
bitmask = tctrl.timeouts(now, {5, 7}); bitmask = tctrl.timeouts(now, {5, 7});
CAF_CHECK_EQUAL(bitmask, 0x00); CAF_CHECK_EQUAL(bitmask, 0x00u);
} }
CAF_TEST(next_timeout) { CAF_TEST(next_timeout) {
......
...@@ -81,7 +81,7 @@ struct fixture { ...@@ -81,7 +81,7 @@ struct fixture {
void fill_ys() { void fill_ys() {
char buf[] = {'\0', '\0'}; char buf[] = {'\0', '\0'};
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
buf[0] = 'a' + i; buf[0] = static_cast<char>('a' + i);
ys.emplace(i + 1, buf); ys.emplace(i + 1, buf);
} }
} }
......
...@@ -98,7 +98,7 @@ struct fetch_helper { ...@@ -98,7 +98,7 @@ struct fetch_helper {
inode& x) { inode& x) {
if (!result.empty()) if (!result.empty())
result += ','; result += ',';
result += to_string(I); result += std::to_string(I);
result += ':'; result += ':';
result += to_string(x); result += to_string(x);
return task_result::resume; return task_result::resume;
...@@ -124,7 +124,7 @@ struct fixture { ...@@ -124,7 +124,7 @@ struct fixture {
auto f = [&](size_t id, drr_queue<inode_policy>&, inode& x) { auto f = [&](size_t id, drr_queue<inode_policy>&, inode& x) {
if (!result.empty()) if (!result.empty())
result += ','; result += ',';
result += to_string(id); result += std::to_string(id);
result += ':'; result += ':';
result += to_string(x); result += to_string(x);
return task_result::resume; return task_result::resume;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment