hello_loopless.cpp 789 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Copyright (c) 2019-2020 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
  3. //
  4. // Distributed under the MIT Software License
  5. //
  6. #include "rotor.hpp"
  7. #include "dummy_supervisor.h"
  8. #include <iostream>
  9. struct hello_actor : public rotor::actor_base_t {
  10. using rotor::actor_base_t::actor_base_t;
  11. void on_start() noexcept override {
  12. rotor::actor_base_t::on_start();
  13. std::cout << "hello world\n";
  14. supervisor->do_shutdown();
  15. }
  16. };
  17. int main() {
  18. rotor::system_context_t ctx{};
  19. auto timeout = boost::posix_time::milliseconds{500}; /* does not matter */
  20. auto sup = ctx.create_supervisor<dummy_supervisor_t>().timeout(timeout).finish();
  21. sup->create_actor<hello_actor>().timeout(timeout).finish();
  22. sup->do_process();
  23. return 0;
  24. }