Horizon Official Technical Documentation
Horizon::System::SystemRoutineManager Class Reference

#include <System.hpp>

Classes

struct  runtime_map_data
 

Public Member Functions

 SystemRoutineManager (runtime_module_type module_type)
 
virtual void register_ (runtime_module_type module_t, runtime_synchronization_method sync_t, std::shared_ptr< RuntimeContext > context)
 
virtual void register_ (runtime_module_type module_t, runtime_synchronization_method sync_t, std::shared_ptr< RuntimeContextChain > context_chain)
 
virtual std::shared_ptr< const runtime_map_datafind_runtime (std::string name)
 
virtual int get_runtime_routine_count ()
 
runtime_module_type get_module_type ()
 
void push (std::shared_ptr< RuntimeContextChain > chain)
 
void push (std::shared_ptr< RuntimeContext > seg)
 
std::shared_ptr< RuntimeContextpop ()
 
std::shared_ptr< RuntimeContextChainpop_chain ()
 
void process_queue ()
 

Public Attributes

boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContext >, boost::lockfree::capacity< 100 > > _system_queue
 
boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContextChain >, boost::lockfree::capacity< 100 > > _system_queue_chain
 

Private Types

typedef std::map< std::string, runtime_map_dataruntime_map
 

Private Attributes

runtime_map _runtime_map
 
runtime_module_type _module_type
 

Member Typedef Documentation

◆ runtime_map

Constructor & Destructor Documentation

◆ SystemRoutineManager()

Horizon::System::SystemRoutineManager::SystemRoutineManager ( runtime_module_type  module_type)
inline
612 : _module_type(module_type)
613 {
614 if (_module_type < RUNTIME_MAIN || _module_type >= Horizon::System::RUNTIME_MODULE_MAX) {
615 std::cerr << "SystemRoutineManager for module type (" << module_type << ") failed to start. Invalid module type." << std::endl;
616 }
617 }
runtime_module_type _module_type
Definition: System.hpp:698
@ RUNTIME_MODULE_MAX
Definition: System.hpp:93

References Horizon::System::RUNTIME_MODULE_MAX.

Member Function Documentation

◆ find_runtime()

virtual std::shared_ptr< const runtime_map_data > Horizon::System::SystemRoutineManager::find_runtime ( std::string  name)
inlinevirtual
632 {
633 auto it = _runtime_map.find(name);
634 return (it != _runtime_map.end()) ? std::make_shared<const runtime_map_data>(it->second) : nullptr;
635 }
runtime_map _runtime_map
Definition: System.hpp:697

References _runtime_map.

◆ get_module_type()

runtime_module_type Horizon::System::SystemRoutineManager::get_module_type ( )
inline
642{ return _module_type; }

References _module_type.

Referenced by push().

+ Here is the caller graph for this function:

◆ get_runtime_routine_count()

virtual int Horizon::System::SystemRoutineManager::get_runtime_routine_count ( )
inlinevirtual
638 {
639 return _runtime_map.size();
640 }

References _runtime_map.

◆ pop()

std::shared_ptr< RuntimeContext > Horizon::System::SystemRoutineManager::pop ( )
inline
654 {
655 if (_system_queue.empty())
656 return nullptr;
657
658 std::shared_ptr<RuntimeContext> ret;
659 _system_queue.pop(ret);
660 return ret;
661 }
boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContext >, boost::lockfree::capacity< 100 > > _system_queue
Definition: System.hpp:693

References _system_queue.

Referenced by process_queue().

+ Here is the caller graph for this function:

◆ pop_chain()

std::shared_ptr< RuntimeContextChain > Horizon::System::SystemRoutineManager::pop_chain ( )
inline
664 {
665 if (_system_queue_chain.empty())
666 return nullptr;
667
668 std::shared_ptr<RuntimeContextChain> ret;
669 _system_queue_chain.pop(ret);
670 return ret;
671 }
boost::lockfree::spsc_queue< std::shared_ptr< RuntimeContextChain >, boost::lockfree::capacity< 100 > > _system_queue_chain
Definition: System.hpp:694

References _system_queue_chain.

Referenced by process_queue().

+ Here is the caller graph for this function:

◆ process_queue()

void Horizon::System::SystemRoutineManager::process_queue ( )
inline
677 {
678 while(_system_queue.empty() == false) {
679 std::shared_ptr<RuntimeContext> context = pop();
680 if (context != nullptr)
681 context->run();
682 }
683
684 while(_system_queue_chain.empty() == false) {
685 std::shared_ptr<RuntimeContextChain> routine_chain = pop_chain();
686 if (routine_chain != nullptr)
687 routine_chain->get_queue_manager().process();
688 }
689 _system_queue.reset();
690 _system_queue_chain.reset();
691 }
std::shared_ptr< RuntimeContextChain > pop_chain()
Definition: System.hpp:663
std::shared_ptr< RuntimeContext > pop()
Definition: System.hpp:653

References _system_queue, _system_queue_chain, pop(), and pop_chain().

Referenced by BOOST_AUTO_TEST_CASE(), KernelComponent::system_routine_process_queue(), Kernel::system_routine_process_queue(), Horizon::Auth::AuthNetworkThread::update(), Horizon::Char::CharNetworkThread::update(), Horizon::Zone::ZoneNetworkThread::update(), Horizon::Zone::ZoneRuntime::update(), Horizon::Zone::GameLogicProcess::update(), Horizon::Zone::PersistenceManager::update(), and Horizon::Zone::ScriptManager::update().

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

◆ push() [1/2]

void Horizon::System::SystemRoutineManager::push ( std::shared_ptr< RuntimeContext seg)
inline
648 {
649 register_(get_module_type(), seg->get_synchronization_method(), seg);
650 _system_queue.push(std::move(seg));
651 }
runtime_module_type get_module_type()
Definition: System.hpp:642
virtual void register_(runtime_module_type module_t, runtime_synchronization_method sync_t, std::shared_ptr< RuntimeContext > context)
Definition: System.hpp:619

References _system_queue, get_module_type(), and register_().

+ Here is the call graph for this function:

◆ push() [2/2]

void Horizon::System::SystemRoutineManager::push ( std::shared_ptr< RuntimeContextChain chain)
inline
644 {
645 register_(chain->get_module_type(), RUNTIME_SYNC_NONE, chain);
646 _system_queue_chain.push(std::move(chain));
647 }
@ RUNTIME_SYNC_NONE
Definition: System.hpp:98

References _system_queue_chain, register_(), and Horizon::System::RUNTIME_SYNC_NONE.

Referenced by BOOST_AUTO_TEST_CASE(), KernelComponent::system_routine_queue_push(), and Kernel::system_routine_queue_push().

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

◆ register_() [1/2]

virtual void Horizon::System::SystemRoutineManager::register_ ( runtime_module_type  module_t,
runtime_synchronization_method  sync_t,
std::shared_ptr< RuntimeContext context 
)
inlinevirtual
620 {
621 runtime_map_data data = { module_t, sync_t, context, nullptr };
622 _runtime_map.emplace(context->get_uuid_string(), data);
623 }

References _runtime_map.

Referenced by push(), KernelComponent::system_routine_register(), and Kernel::system_routine_register().

+ Here is the caller graph for this function:

◆ register_() [2/2]

virtual void Horizon::System::SystemRoutineManager::register_ ( runtime_module_type  module_t,
runtime_synchronization_method  sync_t,
std::shared_ptr< RuntimeContextChain context_chain 
)
inlinevirtual
626 {
627 runtime_map_data data = { module_t, sync_t, nullptr, context_chain };
628 _runtime_map.emplace(context_chain->get_uuid_string(), data);
629 }

References _runtime_map.

Member Data Documentation

◆ _module_type

runtime_module_type Horizon::System::SystemRoutineManager::_module_type
private

Referenced by get_module_type().

◆ _runtime_map

runtime_map Horizon::System::SystemRoutineManager::_runtime_map
private

◆ _system_queue

boost::lockfree::spsc_queue<std::shared_ptr<RuntimeContext>, boost::lockfree::capacity<100> > Horizon::System::SystemRoutineManager::_system_queue

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

◆ _system_queue_chain

boost::lockfree::spsc_queue<std::shared_ptr<RuntimeContextChain>, boost::lockfree::capacity<100> > Horizon::System::SystemRoutineManager::_system_queue_chain

Referenced by pop_chain(), process_queue(), and push().


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