Hi,
> I would like to know if there is a way to configure CAF to run synchronously on just a single thread (only the main thread).
The short answer is no. But there’s also a long answer. it’s not something I would usually recommend, since this comes with a couple of caveats.
There is a scheduler in CAF that does not spin up any threads. It’s called `test_coordinator` since we use it for writing deterministic unit tests.
You can configure CAF to use that instead of the work-stealing scheduler by setting the config parameter `cfg.set("scheduler.policy", caf::atom("testing"));`.
After that, you’ll notice that your application won’t do anything since you have to trigger everything manually now.
For that, you’ll need to get a reference to the scheduler: `auto& sched = dynamic_cast<caf::scheduler::test_coordinator&>(sys.scheduler());`.
The simplest way to just run everything is to call `sched.run()`, but you’ll notice that no timeout gets ever triggered. If you’re using `after()`, `delayed_send()`, requests with timeouts or anything like that, it’s going to get complicated. The test scheduler comes with a fake clock, so you’ll also have to manage time manually. If you’re using CAF’s new streams, this will also mess up credit management.
As long as you’re using a small subset of CAF and only rely on asynchronous messages, this might be feasible. However, anything that touches the clock is going to be tricky.
Hope I could provide at least some insights,
Dominik