Commit 34f3758b authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'master' into topic/remove-atom

parents 18def4a5 264d14b6
......@@ -113,7 +113,7 @@ void read_ini_map(State& ps, Consumer&& consumer) {
state(await_key_name) {
transition(await_key_name, " \t\n")
fsm_epsilon(read_ini_comment(ps, consumer), await_key_name, ';')
transition(read_key_name, alphabetic_chars, key = ch)
transition(read_key_name, alphanumeric_chars, key = ch)
transition(done, '}', consumer.end_map())
}
// Reads a key of a "key=value" line.
......
......@@ -212,6 +212,8 @@ public:
return i->second.ptr;
}
using downstream_manager::close;
void close() override {
CAF_LOG_TRACE(CAF_ARG(paths_));
for (auto ptr : ptrs_)
......
......@@ -189,7 +189,8 @@ public:
};
for (auto id : ids_) {
typename Self::accept_one_cond rc;
self->varargs_receive(rc, id, helper.wrap(), error_handler);
auto error_handler_copy = error_handler;
self->varargs_receive(rc, id, helper.wrap(), error_handler_copy);
}
}
......
......@@ -402,6 +402,8 @@ timespan actor_system_config::stream_tick_duration() const noexcept {
return timespan{ns_count};
}
std::string actor_system_config::render(const error& x) {
if (!x)
return "none";
switch (x.category()) {
case error_category<sec>::value:
return render_sec(x.code(), x.context());
......
......@@ -170,8 +170,6 @@ void error::init() {
}
std::string to_string(const error& x) {
if (!x)
return "none";
return actor_system_config::render(x);
}
......
......@@ -837,6 +837,21 @@ bool scheduled_actor::finalize() {
// Repeated calls always return `true` but have no side effects.
if (getf(is_cleaned_up_flag))
return true;
// TODO: This is a workaround for issue #1011. Iterating over all stream
// managers here and dropping them as needed prevents the
// never-terminating part, but it still means that "dead" stream manager
// can accumulate over time since we only run this O(n) path if the
// actor is shutting down.
if (!has_behavior() && !stream_managers_.empty()) {
for (auto i = stream_managers_.begin(); i != stream_managers_.end();) {
if (i->second->done())
i = stream_managers_.erase(i);
else
++i;
if (stream_managers_.empty())
stream_ticks_.stop();
}
}
// An actor is considered alive as long as it has a behavior and didn't set
// the terminated flag.
if (alive())
......
......@@ -74,6 +74,7 @@ detail::test_actor_clock& test_coordinator::clock() noexcept {
}
void test_coordinator::start() {
CAF_LOG_TRACE("");
dummy_worker worker{this};
actor_config cfg{&worker};
auto& sys = system();
......@@ -82,6 +83,7 @@ void test_coordinator::start() {
}
void test_coordinator::stop() {
CAF_LOG_TRACE("");
while (run() > 0)
trigger_timeouts();
}
......@@ -90,6 +92,7 @@ void test_coordinator::enqueue(resumable* ptr) {
CAF_LOG_TRACE("");
jobs.push_back(ptr);
if (after_next_enqueue_ != nullptr) {
CAF_LOG_DEBUG("inline this enqueue");
std::function<void()> f;
f.swap(after_next_enqueue_);
f();
......@@ -97,6 +100,7 @@ void test_coordinator::enqueue(resumable* ptr) {
}
bool test_coordinator::try_run_once() {
CAF_LOG_TRACE("");
if (jobs.empty())
return false;
auto job = jobs.front();
......@@ -117,6 +121,7 @@ bool test_coordinator::try_run_once() {
}
bool test_coordinator::try_run_once_lifo() {
CAF_LOG_TRACE("");
if (jobs.empty())
return false;
if (jobs.size() >= 2)
......@@ -125,18 +130,21 @@ bool test_coordinator::try_run_once_lifo() {
}
void test_coordinator::run_once() {
CAF_LOG_TRACE("");
if (jobs.empty())
CAF_RAISE_ERROR("No job to run available.");
try_run_once();
}
void test_coordinator::run_once_lifo() {
CAF_LOG_TRACE("");
if (jobs.empty())
CAF_RAISE_ERROR("No job to run available.");
try_run_once_lifo();
}
size_t test_coordinator::run(size_t max_count) {
CAF_LOG_TRACE(CAF_ARG(max_count));
size_t res = 0;
while (res < max_count && try_run_once())
++res;
......@@ -144,16 +152,19 @@ size_t test_coordinator::run(size_t max_count) {
}
void test_coordinator::inline_next_enqueue() {
CAF_LOG_TRACE("");
after_next_enqueue([=] { run_once_lifo(); });
}
void test_coordinator::inline_all_enqueues() {
CAF_LOG_TRACE("");
after_next_enqueue([=] { inline_all_enqueues_helper(); });
}
void test_coordinator::inline_all_enqueues_helper() {
run_once_lifo();
CAF_LOG_TRACE("");
after_next_enqueue([=] { inline_all_enqueues_helper(); });
run_once_lifo();
}
} // namespace caf::scheduler
......@@ -277,4 +277,56 @@ CAF_TEST(invalid inis) {
CAF_CHECK_EQUAL(parse(ini3), ini3_log);
}
CAF_TEST(integer keys are legal in INI syntax) {
static constexpr string_view ini = R"__(
[foo.bar]
1 = 10
2 = 20
)__";
// clang-format off
auto log = make_log(
"key: foo",
"{",
"key: bar",
"{",
"key: 1",
"value (integer): 10",
"key: 2",
"value (integer): 20",
"}",
"}"
);
// clang-format on
CAF_CHECK_EQUAL(parse(ini), log);
}
CAF_TEST(integer keys are legal in config syntax) {
static constexpr string_view ini = R"__(
foo {
bar {
1 = 10
2 = 20
}
}
)__";
// clang-format off
auto log = make_log(
"key: global",
"{",
"key: foo",
"{",
"key: bar",
"{",
"key: 1",
"value (integer): 10",
"key: 2",
"value (integer): 20",
"}",
"}",
"}"
);
// clang-format on
CAF_CHECK_EQUAL(parse(ini), log);
}
CAF_TEST_FIXTURE_SCOPE_END()
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