12345678910111213141516171819202122232425262728293031323334353637 |
- //
- // Copyright (c) 2019 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
- //
- // Distributed under the MIT Software License
- //
- #include "rotor.hpp"
- #include <iostream>
- struct hello_actor : public rotor::actor_base_t {
- using rotor::actor_base_t::actor_base_t;
- void on_start(rotor::message_t<rotor::payload::start_actor_t> &) noexcept override {
- std::cout << "hello world\n";
- supervisor.do_shutdown();
- }
- };
- struct dummy_supervisor : public rotor::supervisor_t {
- using rotor::supervisor_t::supervisor_t;
- void start_timer(const rotor::pt::time_duration &, timer_id_t) noexcept override {}
- void cancel_timer(timer_id_t) noexcept override {}
- void start() noexcept override {}
- void shutdown() noexcept override {}
- void enqueue(rotor::message_ptr_t) noexcept override {}
- };
- int main() {
- rotor::system_context_t ctx{};
- auto timeout = boost::posix_time::milliseconds{500}; /* does not matter */
- rotor::supervisor_config_t cfg{timeout};
- auto sup = ctx.create_supervisor<dummy_supervisor>(nullptr, cfg);
- sup->create_actor<hello_actor>(timeout);
- sup->do_process();
- return 0;
- }
|