Horizon Official Technical Documentation
Horizon::System::RuntimeContextChain::ContextQueueManager Class Reference

#include <System.hpp>

+ Collaboration diagram for Horizon::System::RuntimeContextChain::ContextQueueManager:

Public Member Functions

 ContextQueueManager (ContextControlAgent &control_agent, RuntimeContextChain *chain)
 
virtual void push (std::shared_ptr< RuntimeContext > seg)
 
virtual std::shared_ptr< RuntimeContextpop ()
 
virtual bool process ()
 
virtual bool is_paused ()
 

Public Attributes

ContextControlAgent_control_agent
 
RuntimeContextChain_chain
 
boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContext >, boost::lockfree::capacity< 100 > > _queue
 
std::atomic< bool > _paused {false}
 

Constructor & Destructor Documentation

◆ ContextQueueManager()

Horizon::System::RuntimeContextChain::ContextQueueManager::ContextQueueManager ( ContextControlAgent control_agent,
RuntimeContextChain chain 
)
inline
556: _control_agent(control_agent), _chain(chain) { }
RuntimeContextChain * _chain
Definition: System.hpp:574
ContextControlAgent & _control_agent
Definition: System.hpp:573

Member Function Documentation

◆ is_paused()

virtual bool Horizon::System::RuntimeContextChain::ContextQueueManager::is_paused ( )
inlinevirtual
571{ return _paused; }
std::atomic< bool > _paused
Definition: System.hpp:576

References _paused.

◆ pop()

virtual std::shared_ptr< RuntimeContext > Horizon::System::RuntimeContextChain::ContextQueueManager::pop ( )
inlinevirtual
560 {
561 if (_queue.empty())
562 return nullptr;
563
564 std::shared_ptr<RuntimeContext> ret;
565 _queue.pop(ret);
566 return ret;
567 }
boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContext >, boost::lockfree::capacity< 100 > > _queue
Definition: System.hpp:575

References _queue.

Referenced by Horizon::System::RuntimeContextChain::pop().

+ Here is the caller graph for this function:

◆ process()

bool Horizon::System::RuntimeContextChain::ContextQueueManager::process ( )
virtual
51{
52 std::shared_ptr<RuntimeContext> context = nullptr;
53
55
56 bool failed = false;
57 while((context = pop()) != nullptr) {
59 if (!_paused)
60 _paused = true;
61 }
62
63 if (_paused == true)
64 _paused = false;
65
67 return false;
68
69 if (context->get_routine_manager().get_module_type() != _chain->get_module_type()) {
70 context->dispatch();
71
72 if (context->get_synchronization_method() == RUNTIME_SYNC_WAIT_NO_CHECK_STATE) {
73 while(context->get_context_result() == RUNTIME_CONTEXT_NO_STATE) {
74 if (context->get_context_state() != RUNTIME_CONTEXT_STATE_WAITING) {
75 context->set_context_state(RUNTIME_CONTEXT_STATE_WAITING);
76 }
77 }
78
79 if (context->get_context_state() == RUNTIME_CONTEXT_STATE_WAITING) {
80 context->set_context_state(RUNTIME_CONTEXT_STATE_ACTIVE);
81 }
82 /* Don't check the pass or fail of the context. */
83 } else if (context->get_synchronization_method() == RUNTIME_SYNC_WAIT_CHECK_STATE) {
84 while(context->get_context_result() == RUNTIME_CONTEXT_NO_STATE) {
85 if (context->get_context_state() != RUNTIME_CONTEXT_STATE_WAITING) {
86 context->set_context_state(RUNTIME_CONTEXT_STATE_WAITING);
87 }
88 }
89 if (context->get_context_state() == RUNTIME_CONTEXT_STATE_WAITING) {
90 context->set_context_state(RUNTIME_CONTEXT_STATE_ACTIVE);
91 }
92 /* check context result whether pass or fail. */
93 if (context->get_context_result() == RUNTIME_CONTEXT_FAIL) {
94 failed = true;
95 break;
96 }
97 }
98
99 } else if (context->run() == false) {
100 failed = true;
101 break;
102 }
103 }
104
105 _queue.reset();
106
107 if (failed == true) {
109 return false;
110 }
111
113
114 return true;
115}
runtime_routine_chain_status get_status()
Definition: System.hpp:548
virtual std::shared_ptr< RuntimeContext > pop()
Definition: System.hpp:559
runtime_module_type get_module_type()
Definition: System.hpp:589
@ RUNTIME_CONTEXT_FAIL
Definition: System.hpp:108
@ RUNTIME_CONTEXT_NO_STATE
Definition: System.hpp:107
@ RUNTIME_CONTEXT_STATE_ACTIVE
Definition: System.hpp:115
@ RUNTIME_CONTEXT_STATE_WAITING
Definition: System.hpp:116
@ RUNTIME_ROUTINE_CHAIN_CANCELLED
Definition: System.hpp:58
@ RUNTIME_ROUTINE_CHAIN_PAUSED
Definition: System.hpp:56
@ RUNTIME_ROUTINE_CHAIN_STOPPED
Definition: System.hpp:54
@ RUNTIME_SYNC_WAIT_CHECK_STATE
Definition: System.hpp:100
@ RUNTIME_SYNC_WAIT_NO_CHECK_STATE
Definition: System.hpp:99

References Horizon::System::RUNTIME_CONTEXT_FAIL, Horizon::System::RUNTIME_CONTEXT_NO_STATE, Horizon::System::RUNTIME_CONTEXT_STATE_ACTIVE, Horizon::System::RUNTIME_CONTEXT_STATE_WAITING, Horizon::System::RUNTIME_ROUTINE_CHAIN_CANCELLED, Horizon::System::RUNTIME_ROUTINE_CHAIN_PAUSED, Horizon::System::RUNTIME_ROUTINE_CHAIN_STOPPED, Horizon::System::RUNTIME_SYNC_WAIT_CHECK_STATE, and Horizon::System::RUNTIME_SYNC_WAIT_NO_CHECK_STATE.

Referenced by Horizon::System::RuntimeContextChain::process().

+ Here is the caller graph for this function:

◆ push()

virtual void Horizon::System::RuntimeContextChain::ContextQueueManager::push ( std::shared_ptr< RuntimeContext seg)
inlinevirtual
558{ _queue.push(std::move(seg)); }

References _queue.

Referenced by Horizon::System::RuntimeContextChain::push().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _chain

RuntimeContextChain* Horizon::System::RuntimeContextChain::ContextQueueManager::_chain

◆ _control_agent

ContextControlAgent& Horizon::System::RuntimeContextChain::ContextQueueManager::_control_agent

◆ _paused

std::atomic<bool> Horizon::System::RuntimeContextChain::ContextQueueManager::_paused {false}

Referenced by is_paused().

◆ _queue

boost::lockfree::spsc_queue<std::shared_ptr<RuntimeContext>, boost::lockfree::capacity<100> > Horizon::System::RuntimeContextChain::ContextQueueManager::_queue

Referenced by pop(), and push().


The documentation for this class was generated from the following files: