Horizon Official Technical Documentation
Horizon::System::RuntimeContext::WorkQueueManager Class Reference

#include <System.hpp>

+ Collaboration diagram for Horizon::System::RuntimeContext::WorkQueueManager:

Public Member Functions

 WorkQueueManager (WorkControlAgent &control_agent)
 
void push (std::shared_ptr< WorkContext > seg)
 
std::shared_ptr< WorkContextpop ()
 
bool process ()
 
bool is_paused ()
 

Public Attributes

WorkControlAgent_control_agent
 
boost::lockfree::spsc_queue< std::shared_ptr< WorkContext >, boost::lockfree::capacity< 100 > > _queue
 
std::atomic< bool > _paused {false}
 

Constructor & Destructor Documentation

◆ WorkQueueManager()

Horizon::System::RuntimeContext::WorkQueueManager::WorkQueueManager ( WorkControlAgent control_agent)
inline
230: _control_agent(control_agent) { }
WorkControlAgent & _control_agent
Definition: System.hpp:285

Member Function Documentation

◆ is_paused()

bool Horizon::System::RuntimeContext::WorkQueueManager::is_paused ( )
inline
284{ return _paused; }
std::atomic< bool > _paused
Definition: System.hpp:287

References _paused.

◆ pop()

std::shared_ptr< WorkContext > Horizon::System::RuntimeContext::WorkQueueManager::pop ( )
inline
234 {
235 if (_queue.empty())
236 return nullptr;
237
238 std::shared_ptr<WorkContext> ret;
239 _queue.pop(ret);
240 return ret;
241 }
boost::lockfree::spsc_queue< std::shared_ptr< WorkContext >, boost::lockfree::capacity< 100 > > _queue
Definition: System.hpp:286

References _queue.

Referenced by Horizon::System::RuntimeContext::pop(), and process().

+ Here is the caller graph for this function:

◆ process()

bool Horizon::System::RuntimeContext::WorkQueueManager::process ( )
inline
244 {
245 std::shared_ptr<WorkContext> context = nullptr;
246
247 //_control_agent.start();
248
249 bool failed = false;
250
251 while((context = pop()) != nullptr) {
253 if (!_paused)
254 _paused = true;
255 }
256
257 if (_paused == true)
258 _paused = false;
259
261 return false;
262 }
263
264 // break on execution failure.
265 if (context->execute() == false) {
266 failed = true;
267 break;
268 }
269
270 }
271
272 _queue.reset();
273
274 if (failed == true) {
276 return false;
277 }
278
280
281 return true;
282 }
runtime_work_queue_status get_status()
Definition: System.hpp:222
bool failed()
Definition: System.hpp:211
bool completed()
Definition: System.hpp:200
std::shared_ptr< WorkContext > pop()
Definition: System.hpp:233
@ RUNTIME_WORK_QUEUE_PAUSED
Definition: System.hpp:67
@ RUNTIME_WORK_QUEUE_STOPPED
Definition: System.hpp:65
@ RUNTIME_WORK_QUEUE_CANCELLED
Definition: System.hpp:69

References _control_agent, _paused, _queue, Horizon::System::RuntimeContext::WorkControlAgent::completed(), Horizon::System::RuntimeContext::WorkControlAgent::failed(), Horizon::System::RuntimeContext::WorkControlAgent::get_status(), pop(), Horizon::System::RUNTIME_WORK_QUEUE_CANCELLED, Horizon::System::RUNTIME_WORK_QUEUE_PAUSED, and Horizon::System::RUNTIME_WORK_QUEUE_STOPPED.

Referenced by Horizon::System::RuntimeContext::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push()

void Horizon::System::RuntimeContext::WorkQueueManager::push ( std::shared_ptr< WorkContext seg)
inline
232{ _queue.push(std::move(seg)); }

References _queue.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ _control_agent

WorkControlAgent& Horizon::System::RuntimeContext::WorkQueueManager::_control_agent

Referenced by process().

◆ _paused

std::atomic<bool> Horizon::System::RuntimeContext::WorkQueueManager::_paused {false}

Referenced by is_paused(), and process().

◆ _queue

boost::lockfree::spsc_queue<std::shared_ptr<WorkContext>, boost::lockfree::capacity<100> > Horizon::System::RuntimeContext::WorkQueueManager::_queue

Referenced by pop(), process(), and push().


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