015-resources.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "access.h"
  7. #include "rotor.hpp"
  8. #include "supervisor_test.h"
  9. #include "actor_test.h"
  10. namespace r = rotor;
  11. namespace rt = r::test;
  12. TEST_CASE("release/acquire resources, when other actor is in progress of configuration", "[plugin]") {
  13. r::system_context_t system_context;
  14. auto sup = system_context.create_supervisor<rt::supervisor_test_t>()
  15. .timeout(rt::default_timeout)
  16. .create_registry(true)
  17. .finish();
  18. auto act = sup->create_actor<rt::actor_test_t>().timeout(rt::default_timeout).finish();
  19. act->configurer = [&](auto &, r::plugin::plugin_base_t &plugin) {
  20. plugin.with_casted<r::plugin::starter_plugin_t>([&](auto &) {
  21. auto res = act->access<rt::to::resources>();
  22. res->acquire(0);
  23. res->release(0);
  24. });
  25. };
  26. sup->do_process();
  27. CHECK(sup->get_state() == r::state_t::OPERATIONAL);
  28. CHECK(act->get_state() == r::state_t::OPERATIONAL);
  29. sup->do_shutdown();
  30. sup->do_process();
  31. CHECK(sup->get_state() == r::state_t::SHUT_DOWN);
  32. CHECK(act->get_state() == r::state_t::SHUT_DOWN);
  33. }