Horizon Official Technical Documentation
KernelComponent Class Reference

#include <Server.hpp>

+ Inheritance diagram for KernelComponent:
+ Collaboration diagram for KernelComponent:

Public Member Functions

 KernelComponent (Kernel *kernel, Horizon::System::runtime_module_type module_type)
 
virtual void initialize (int segment_number=1)
 
virtual void finalize ()
 
virtual bool is_initialized ()
 
virtual bool is_finalized ()
 
void set_segment_number (int64_t segment_number)
 
int64_t get_segment_number ()
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContext > context)
 
void system_routine_queue_push (std::shared_ptr< Horizon::System::RuntimeContextChain > context)
 
void system_routine_process_queue ()
 
void system_routine_register (Horizon::System::runtime_module_type module_t, Horizon::System::runtime_synchronization_method sync_t, std::shared_ptr< Horizon::System::RuntimeContext > context)
 
const std::string get_uuid_string ()
 
const std::string get_type_string ()
 
Horizon::System::SystemRoutineManagerget_system_routine_manager ()
 
Kernelget_kernel ()
 
void set_thread_cpu_id (int cpu_id)
 
int get_thread_cpu_id ()
 
void set_thread_update_rate (double rate)
 
double get_thread_update_rate ()
 
void set_total_execution_time (int time)
 
int get_total_execution_time ()
 
void calculate_and_set_cpu_load ()
 

Private Attributes

std::atomic< int64_t > _segment_number {0}
 
Horizon::System::runtime_module_type _module_type {Horizon::System::RUNTIME_MAIN}
 
Horizon::System::SystemRoutineManager _hsr_manager
 
boost::uuids::uuid _uuid
 
std::atomic< int > _thread_cpu_id {0}
 
Kernel_kernel {nullptr}
 
int _update_count {0}
 
std::chrono::steady_clock::time_point _last_thread_update_rate_time
 
std::chrono::steady_clock::time_point _last_total_execution_time_update
 
std::atomic< double > _thread_update_rate {0.0}
 
int _total_execution_time_aggregate {0}
 
std::atomic< int > _total_execution_time_average {0}
 

Constructor & Destructor Documentation

◆ KernelComponent()

KernelComponent::KernelComponent ( Kernel kernel,
Horizon::System::runtime_module_type  module_type 
)
inline
195 : _kernel(kernel), _module_type(module_type), _hsr_manager(module_type), _uuid(boost::uuids::random_generator()())
196 { }
Horizon::System::runtime_module_type _module_type
Definition: Server.hpp:274
boost::uuids::uuid _uuid
Definition: Server.hpp:276
Horizon::System::SystemRoutineManager _hsr_manager
Definition: Server.hpp:275
Kernel * _kernel
Definition: Server.hpp:279

Member Function Documentation

◆ calculate_and_set_cpu_load()

void KernelComponent::calculate_and_set_cpu_load ( )
inline
258 {
260
261 // Update thread update rate every second to determine the number of updates per second
262 auto current_time = std::chrono::steady_clock::now();
263 auto diff_time = std::chrono::duration_cast<std::chrono::nanoseconds>(current_time - _last_thread_update_rate_time).count();
264 if (diff_time >= 1e9) {
265 double update_rate = _update_count / (diff_time / 1e9);
266 set_thread_update_rate(update_rate);
267 _update_count = 0;
268 _last_thread_update_rate_time = current_time;
269 }
270 }
int _update_count
Definition: Server.hpp:280
std::chrono::steady_clock::time_point _last_thread_update_rate_time
Definition: Server.hpp:281
void set_thread_update_rate(double rate)
Definition: Server.hpp:242

References _last_thread_update_rate_time, _update_count, and set_thread_update_rate().

Referenced by CommandLineProcess::cli_thread_start(), DatabaseProcess::initialize(), 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:

◆ finalize()

◆ get_kernel()

Kernel * KernelComponent::get_kernel ( )
inline
237{ return _kernel; }

References _kernel.

Referenced by CommandLineProcess::clicmd_kernel_info().

+ Here is the caller graph for this function:

◆ get_segment_number()

int64_t KernelComponent::get_segment_number ( )
inline
207{ return _segment_number.load(); }
std::atomic< int64_t > _segment_number
Definition: Server.hpp:273

References _segment_number.

Referenced by DatabaseProcess::reinitialize(), and Horizon::Zone::GameLogicProcess::start_internal().

+ Here is the caller graph for this function:

◆ get_system_routine_manager()

◆ get_thread_cpu_id()

◆ get_thread_update_rate()

double KernelComponent::get_thread_update_rate ( )
inline
243{ return _thread_update_rate.load(); }
std::atomic< double > _thread_update_rate
Definition: Server.hpp:283

References _thread_update_rate.

Referenced by set_total_execution_time().

+ Here is the caller graph for this function:

◆ get_total_execution_time()

int KernelComponent::get_total_execution_time ( )
inline
255{ return _total_execution_time_average.load(); }
std::atomic< int > _total_execution_time_average
Definition: Server.hpp:285

References _total_execution_time_average.

◆ get_type_string()

const std::string KernelComponent::get_type_string ( )
inline
217 {
218 switch (_module_type)
219 {
220 case Horizon::System::RUNTIME_MAIN: return "Main";
221 case Horizon::System::RUNTIME_GAMELOGIC: return "Game-logic";
222 case Horizon::System::RUNTIME_PERSISTENCE: return "Persistence";
223 case Horizon::System::RUNTIME_DATABASE: return "Database";
224 case Horizon::System::RUNTIME_COMMANDLINE: return "Command-Line";
225 case Horizon::System::RUNTIME_SCRIPTVM: return "Script-VM";
226 case Horizon::System::RUNTIME_NETWORKING: return "Networking";
227 case Horizon::System::RUNTIME_RUNTIME: return "Runtime";
228 case Horizon::System::RUNTIME_CLIENT_NETWORKING: return "Client-Networking";
229 case Horizon::System::RUNTIME_HTTP_SERVICE: return "Http Service";
230 case Horizon::System::RUNTIME_WEB_SOCKET: return "Web Socket Service";
231 default: return "Unknown";
232 }
233 }
@ RUNTIME_CLIENT_NETWORKING
Definition: System.hpp:89
@ RUNTIME_DATABASE
Definition: System.hpp:88
@ RUNTIME_NETWORKING
Definition: System.hpp:84
@ RUNTIME_WEB_SOCKET
Definition: System.hpp:91
@ RUNTIME_HTTP_SERVICE
Definition: System.hpp:90
@ RUNTIME_MAIN
Definition: System.hpp:82
@ RUNTIME_SCRIPTVM
Definition: System.hpp:87
@ RUNTIME_GAMELOGIC
Definition: System.hpp:86
@ RUNTIME_COMMANDLINE
Definition: System.hpp:83
@ RUNTIME_PERSISTENCE
Definition: System.hpp:85
@ RUNTIME_RUNTIME
Definition: System.hpp:92

References _module_type, Horizon::System::RUNTIME_CLIENT_NETWORKING, Horizon::System::RUNTIME_COMMANDLINE, Horizon::System::RUNTIME_DATABASE, Horizon::System::RUNTIME_GAMELOGIC, Horizon::System::RUNTIME_HTTP_SERVICE, Horizon::System::RUNTIME_MAIN, Horizon::System::RUNTIME_NETWORKING, Horizon::System::RUNTIME_PERSISTENCE, Horizon::System::RUNTIME_RUNTIME, Horizon::System::RUNTIME_SCRIPTVM, and Horizon::System::RUNTIME_WEB_SOCKET.

◆ get_uuid_string()

const std::string KernelComponent::get_uuid_string ( )
inline
214{ return boost::uuids::to_string(_uuid); }

References _uuid.

◆ initialize()

virtual void KernelComponent::initialize ( int  segment_number = 1)
inlinevirtual

◆ is_finalized()

◆ is_initialized()

◆ set_segment_number()

◆ set_thread_cpu_id()

◆ set_thread_update_rate()

void KernelComponent::set_thread_update_rate ( double  rate)
inline
242{ _thread_update_rate.exchange(rate); }

References _thread_update_rate.

Referenced by calculate_and_set_cpu_load().

+ Here is the caller graph for this function:

◆ set_total_execution_time()

void KernelComponent::set_total_execution_time ( int  time)
inline
246 {
248
249 if (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _last_total_execution_time_update).count() >= 1) {
250 _last_total_execution_time_update = std::chrono::steady_clock::now();
253 }
254 }
std::chrono::steady_clock::time_point _last_total_execution_time_update
Definition: Server.hpp:282
int _total_execution_time_aggregate
Definition: Server.hpp:284
double get_thread_update_rate()
Definition: Server.hpp:243
size_t count(GridTypeListContainer< SPECIFIC_TYPE > const &elements, SPECIFIC_TYPE *)
Definition: GridReferenceContainer.hpp:100

References _last_total_execution_time_update, _total_execution_time_aggregate, _total_execution_time_average, GridTypeListIterator::count(), and get_thread_update_rate().

Referenced by 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:

◆ system_routine_process_queue()

void KernelComponent::system_routine_process_queue ( )
void process_queue()
Definition: System.hpp:676

References _hsr_manager, and Horizon::System::SystemRoutineManager::process_queue().

+ Here is the call graph for this function:

◆ system_routine_queue_push() [1/2]

void KernelComponent::system_routine_queue_push ( std::shared_ptr< Horizon::System::RuntimeContext context)
75{ _hsr_manager.push(context); }
void push(std::shared_ptr< RuntimeContextChain > chain)
Definition: System.hpp:644

References _hsr_manager, and Horizon::System::SystemRoutineManager::push().

+ Here is the call graph for this function:

◆ system_routine_queue_push() [2/2]

void KernelComponent::system_routine_queue_push ( std::shared_ptr< Horizon::System::RuntimeContextChain context)
76{ _hsr_manager.push(context); }

References _hsr_manager, and Horizon::System::SystemRoutineManager::push().

+ Here is the call graph for this function:

◆ system_routine_register()

void KernelComponent::system_routine_register ( Horizon::System::runtime_module_type  module_t,
Horizon::System::runtime_synchronization_method  sync_t,
std::shared_ptr< Horizon::System::RuntimeContext context 
)
79{
80 _hsr_manager.register_(module_t, sync_t, context);
81}
virtual void register_(runtime_module_type module_t, runtime_synchronization_method sync_t, std::shared_ptr< RuntimeContext > context)
Definition: System.hpp:619

References _hsr_manager, and Horizon::System::SystemRoutineManager::register_().

+ Here is the call graph for this function:

Member Data Documentation

◆ _hsr_manager

◆ _kernel

Kernel* KernelComponent::_kernel {nullptr}
private

Referenced by get_kernel().

◆ _last_thread_update_rate_time

std::chrono::steady_clock::time_point KernelComponent::_last_thread_update_rate_time
private

◆ _last_total_execution_time_update

std::chrono::steady_clock::time_point KernelComponent::_last_total_execution_time_update
private

◆ _module_type

Referenced by get_type_string().

◆ _segment_number

std::atomic<int64_t> KernelComponent::_segment_number {0}
private

◆ _thread_cpu_id

std::atomic<int> KernelComponent::_thread_cpu_id {0}
private

◆ _thread_update_rate

std::atomic<double> KernelComponent::_thread_update_rate {0.0}
private

◆ _total_execution_time_aggregate

int KernelComponent::_total_execution_time_aggregate {0}
private

◆ _total_execution_time_average

std::atomic<int> KernelComponent::_total_execution_time_average {0}
private

◆ _update_count

int KernelComponent::_update_count {0}
private

◆ _uuid

boost::uuids::uuid KernelComponent::_uuid
private

Referenced by get_uuid_string().


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