void update(const chrono::time_point& system_time, const chrono::time_point& internal_time) { if (config::metrics_dump_opts.interval.count() == 0) { return; } if (system_time - dump_timestamp > config::metrics_dump_opts.interval) { internal::update_metrics(internal_time); internal::stats::update(system_time); message_queue::stats::update(system_time); stats::update(system_time); auto new_dump = create_dump(); { std::lock_guard<std::mutex> lock(dump_mutex); dump = new_dump; } dump_timestamp = system_time; } }
int main(int argc, char *argv[]) { /* * * Load logging module * if error return process */ if(logging()) { log4c_category_log( log_handler, LOG4C_PRIORITY_FATAL, "sync: primary process startup -- failed"); return -1; } log4c_category_log( log_handler, LOG4C_PRIORITY_DEBUG, "sync: primary process startup -- successful"); /* *Load configure files *initate server */ if(initServerConfig()) { log4c_category_log( log_handler, LOG4C_PRIORITY_FATAL, "sync: initiate server configure -- failed"); return -3; } log4c_category_log( log_handler, LOG4C_PRIORITY_DEBUG, "sync: initiate server configure -- successful"); /* *Create daemon *if error return process */ if(xdaemon()) { log4c_category_log( log_handler, LOG4C_PRIORITY_FATAL, "sync: process into daemon state -- failed"); return -2; } log4c_category_log( log_handler, LOG4C_PRIORITY_DEBUG, "sync: process into daemon state -- successful"); /* *Create queue *store receiver item */ if(create_queue()) { log4c_category_log( log_handler, LOG4C_PRIORITY_FATAL, "sync: create queue -- failed"); return -4; } log4c_category_log( log_handler, LOG4C_PRIORITY_DEBUG, "sync: create queue -- successful"); /* *create dump file *when MySQL lost connect */ if(create_dump()) { log4c_category_log( log_handler, LOG4C_PRIORITY_FATAL, "sync: create dump file -- failed"); } log4c_category_log( log_handler, LOG4C_PRIORITY_DEBUG, "sync: create queue -- successful"); /* *Create some process include: *one receiver *many mysql-connector */ create_thread(); /* * Process never run to here */ return EXIT_SUCCESS; }