Unverified Commit cc0982b5 authored by Joseph Noir's avatar Joseph Noir Committed by GitHub

Merge pull request #1017

Fix inline_all_enqueues, add trace logging
parents bd831d0c c1b9ee3d
...@@ -74,6 +74,7 @@ detail::test_actor_clock& test_coordinator::clock() noexcept { ...@@ -74,6 +74,7 @@ detail::test_actor_clock& test_coordinator::clock() noexcept {
} }
void test_coordinator::start() { void test_coordinator::start() {
CAF_LOG_TRACE("");
dummy_worker worker{this}; dummy_worker worker{this};
actor_config cfg{&worker}; actor_config cfg{&worker};
auto& sys = system(); auto& sys = system();
...@@ -82,6 +83,7 @@ void test_coordinator::start() { ...@@ -82,6 +83,7 @@ void test_coordinator::start() {
} }
void test_coordinator::stop() { void test_coordinator::stop() {
CAF_LOG_TRACE("");
while (run() > 0) while (run() > 0)
trigger_timeouts(); trigger_timeouts();
} }
...@@ -90,6 +92,7 @@ void test_coordinator::enqueue(resumable* ptr) { ...@@ -90,6 +92,7 @@ void test_coordinator::enqueue(resumable* ptr) {
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
jobs.push_back(ptr); jobs.push_back(ptr);
if (after_next_enqueue_ != nullptr) { if (after_next_enqueue_ != nullptr) {
CAF_LOG_DEBUG("inline this enqueue");
std::function<void()> f; std::function<void()> f;
f.swap(after_next_enqueue_); f.swap(after_next_enqueue_);
f(); f();
...@@ -97,6 +100,7 @@ void test_coordinator::enqueue(resumable* ptr) { ...@@ -97,6 +100,7 @@ void test_coordinator::enqueue(resumable* ptr) {
} }
bool test_coordinator::try_run_once() { bool test_coordinator::try_run_once() {
CAF_LOG_TRACE("");
if (jobs.empty()) if (jobs.empty())
return false; return false;
auto job = jobs.front(); auto job = jobs.front();
...@@ -117,6 +121,7 @@ bool test_coordinator::try_run_once() { ...@@ -117,6 +121,7 @@ bool test_coordinator::try_run_once() {
} }
bool test_coordinator::try_run_once_lifo() { bool test_coordinator::try_run_once_lifo() {
CAF_LOG_TRACE("");
if (jobs.empty()) if (jobs.empty())
return false; return false;
if (jobs.size() >= 2) if (jobs.size() >= 2)
...@@ -125,18 +130,21 @@ bool test_coordinator::try_run_once_lifo() { ...@@ -125,18 +130,21 @@ bool test_coordinator::try_run_once_lifo() {
} }
void test_coordinator::run_once() { void test_coordinator::run_once() {
CAF_LOG_TRACE("");
if (jobs.empty()) if (jobs.empty())
CAF_RAISE_ERROR("No job to run available."); CAF_RAISE_ERROR("No job to run available.");
try_run_once(); try_run_once();
} }
void test_coordinator::run_once_lifo() { void test_coordinator::run_once_lifo() {
CAF_LOG_TRACE("");
if (jobs.empty()) if (jobs.empty())
CAF_RAISE_ERROR("No job to run available."); CAF_RAISE_ERROR("No job to run available.");
try_run_once_lifo(); try_run_once_lifo();
} }
size_t test_coordinator::run(size_t max_count) { size_t test_coordinator::run(size_t max_count) {
CAF_LOG_TRACE(CAF_ARG(max_count));
size_t res = 0; size_t res = 0;
while (res < max_count && try_run_once()) while (res < max_count && try_run_once())
++res; ++res;
...@@ -144,16 +152,19 @@ size_t test_coordinator::run(size_t max_count) { ...@@ -144,16 +152,19 @@ size_t test_coordinator::run(size_t max_count) {
} }
void test_coordinator::inline_next_enqueue() { void test_coordinator::inline_next_enqueue() {
CAF_LOG_TRACE("");
after_next_enqueue([=] { run_once_lifo(); }); after_next_enqueue([=] { run_once_lifo(); });
} }
void test_coordinator::inline_all_enqueues() { void test_coordinator::inline_all_enqueues() {
CAF_LOG_TRACE("");
after_next_enqueue([=] { inline_all_enqueues_helper(); }); after_next_enqueue([=] { inline_all_enqueues_helper(); });
} }
void test_coordinator::inline_all_enqueues_helper() { void test_coordinator::inline_all_enqueues_helper() {
run_once_lifo(); CAF_LOG_TRACE("");
after_next_enqueue([=] { inline_all_enqueues_helper(); }); after_next_enqueue([=] { inline_all_enqueues_helper(); });
run_once_lifo();
} }
} // namespace caf::scheduler } // namespace caf::scheduler
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