int main(int argc, char *argv[]) { printf("test001\n"); char *msg_pub = "hhhhhhhhhhhhhhhhhhhhhh"; char *msg_topic1 = "mqtt"; // rc_sub_thread = pthread_create(&pthread_sub_thread, NULL, sub_thread, NULL); //main_mosquitto_sub(argc, char *argv[]); //main_mosquitto_pub(int argc, char *argv[]); // while(1) { pub_message(msg_topic1, msg_pub); printf("test while 01\n"); sleep(2); } printf("test002\n"); return 0; }
void ImpTradeSession::session_manager_procedure(void) { std::cout << "-> SESSION_MANAGER_PROCEDURE STARTUP." << std::endl; std::mutex mtx; std::unique_lock<std::mutex> lck(mtx); while (_worker_running) { try { std::this_thread::sleep_for (std::chrono::seconds(1)); int day, tm; get_current_dt(day, tm); if (tm >= this->_startTime && tm < this->_endTime) { if (!this->_is_login) { this->login(); this->_is_login = true; } else { // check _heartBtInt if (_last_exec_time > tm) _last_exec_time = tm; if (second_between_time(_last_exec_time, tm) >= _heartBtInt) { //调用心跳 std::cout << "-> WORKER_PROCEDURE HEARTBEATS:" << tm << std::endl; pub_message(TradeAPI::MessageType::MTInfo, "WORKER_PROCEDURE HEARTBEATS AT: %d", tm); call_410502(); } } } else { if (this->_is_login) { this->_is_login = false; this->logout(); clear_all_orders(); } } } catch (std::exception &e) { std::cout << e.what() << std::endl; } } std::cout << "-> SESSION_MANAGER_PROCEDURE STOPPED." << std::endl; }