inter.inline.h 2.2 KB

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