core_inter.inline.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef AFUN_CORE_INTER_INLINE_H
  2. #define AFUN_CORE_INTER_INLINE_H
  3. #include "core_inter.h"
  4. namespace aFuncore {
  5. Environment &Inter::getEnvironment() {
  6. return env;
  7. }
  8. void Inter::pushActivation(Activation *new_activation) {
  9. stack.push_front(new_activation);
  10. activation = new_activation;
  11. }
  12. Activation *Inter::popActivation() {
  13. if (activation == nullptr)
  14. return nullptr;
  15. Activation *ret = activation;
  16. stack.pop_front();
  17. if (stack.empty())
  18. activation = nullptr;
  19. else
  20. activation = stack.front();
  21. return ret;
  22. }
  23. Inter::InterStatus Inter::getStatus() const {
  24. return status;
  25. }
  26. bool Inter::isInterStop() const {
  27. return (status == inter_exit || status == inter_stop);
  28. }
  29. bool Inter::isInterExit() const {
  30. return (status == inter_exit);
  31. }
  32. const std::list<Activation *> &Inter::getStack() const {
  33. return stack;
  34. }
  35. Activation *Inter::getActivation() const {
  36. return activation;
  37. }
  38. EnvVarSpace &Inter::getEnvVarSpace() {
  39. return env.env_var;
  40. }
  41. InterOutMessageStream &Inter::getOutMessageStream() {
  42. return out;
  43. }
  44. InterInMessageStream &Inter::getInMessageStream() {
  45. return in;
  46. }
  47. size_t Environment::operator++(){
  48. std::unique_lock<std::mutex> mutex{lock};
  49. return ++reference;
  50. }
  51. size_t Environment::operator--(){
  52. std::unique_lock<std::mutex> mutex{lock};
  53. return --reference;
  54. }
  55. size_t Environment::operator++(int){
  56. std::unique_lock<std::mutex> mutex{lock};
  57. return reference++;
  58. }
  59. size_t Environment::operator--(int){
  60. std::unique_lock<std::mutex> mutex{lock};
  61. return reference--;
  62. }
  63. Inter::InterStatus Inter::setInterStop() {
  64. InterStatus ret = status;
  65. if (status != inter_exit)
  66. status = inter_stop;
  67. return ret;
  68. }
  69. Inter::InterStatus Inter::setInterExit() {
  70. InterStatus ret = status;
  71. status = inter_exit;
  72. return ret;
  73. }
  74. }
  75. #endif //AFUN_CORE_INTER_INLINE_H