void MainControl::on_clean_up() { #if defined(DEBUG) || defined(CONSOLE) cout << "execute clean up message!\n"; #endif if( m_fclean ) { #if defined(DEBUG) cout << "ignoring clean up message!\n"; #endif return; } m_fclean = true; if( GNR::is_holiday() ) { #if defined(DEBUG) || defined(CONSOLE) cout << "today is holiday!\n"; #endif m_fstart = true; return; } GNR::set_date(TDU::int_date()); //////////////////////////////////////////////////////////// // stop & destroy server //////////////////////////////////////////////////////////// mkt_socket_listen(CLS_DESTROY); idx_socket_data(CLS_DESTROY); idx_data_manager(CLS_DESTROY); mkt_client_manager(CLS_DESTROY); data_storage(CLS_DESTROY); //////////////////////////////////////////////////////////// // create & start server //////////////////////////////////////////////////////////// data_storage(CLS_CREATE_START); idx_data_manager(CLS_CREATE); mkt_client_manager(CLS_CREATE_START); idx_socket_data(CLS_CREATE); mkt_socket_listen(CLS_CREATE_START); }
void constructorTest() { // Construct an empty storage thunder::Storage< T > default_storage; EXPECT_EQ(0, default_storage.size()); EXPECT_EQ(nullptr, default_storage.data()); // Construct an empty storage using explicit size thunder::Storage< T > size_empty_storage(0); EXPECT_EQ(0, size_empty_storage.size()); EXPECT_EQ(nullptr, size_empty_storage.data()); // Construct an empty storage from copy constructor thunder::Storage< T > copy_empty_storage(default_storage); EXPECT_EQ(0, copy_empty_storage.size()); EXPECT_EQ(nullptr, copy_empty_storage.data()); // Construct an storage with some size thunder::Storage< T > size_storage(5); int size_storage_val = 0; for (typename thunder::Storage< T >::size_type i = 0; i < 5; ++i) { size_storage[i] = static_cast< T >(size_storage_val++); } EXPECT_EQ(5, size_storage.size()); EXPECT_NE(nullptr, size_storage.data()); // Construct an storage with some size and a default value thunder::Storage< T > size_value_storage(5, (T)3); EXPECT_EQ(5, size_storage.size()); EXPECT_NE(nullptr, size_value_storage.data()); for (int i = 0; i < 5; ++i) { EXPECT_EQ((T)3, size_value_storage.data()[i]); } // Copy construct a storage thunder::Storage< T > copy_storage(size_storage); EXPECT_EQ(5, copy_storage.size()); EXPECT_NE(nullptr, copy_storage.data()); for (int i = 0; i < 5; ++i) { EXPECT_EQ(size_storage.data()[i], copy_storage.data()[i]); } // Initialzation list constructor thunder::Storage< T > init_storage({3, 4, 5, 6, 7}); EXPECT_EQ(5, init_storage.size()); EXPECT_NE(nullptr, init_storage.data()); for (int i = 0; i < 5; ++i) { EXPECT_EQ(static_cast< T >(i + 3), init_storage.data()[i]); } // Construct an storage using external data thunder::Storage< T > data_storage( init_storage.data(), init_storage.size()); EXPECT_EQ(5, data_storage.size()); EXPECT_NE(nullptr, data_storage.data()); EXPECT_EQ(init_storage.data(), data_storage.data()); for (int i = 0; i < 5; ++i) { EXPECT_EQ(static_cast< T >(i + 3), data_storage.data()[i]); } // Construct a storage using external shared data thunder::Storage< T > shared_storage( init_storage.shared(), init_storage.size()); EXPECT_EQ(5, shared_storage.size()); EXPECT_NE(nullptr, shared_storage.data()); EXPECT_EQ(init_storage.data(), shared_storage.data()); for (int i = 0; i < 5; ++i) { EXPECT_EQ(static_cast< T >(i + 3), shared_storage.data()[i]); } }
void MainControl::on_exit_thread() { #if defined(DEBUG) cout << "MainControl exit thread!\n"; #endif //////////////////////////////////////////////////////////////// // stop timer thread //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start timer exit thread!\n"; timer_thread(CLS_STOP); cout << "finish timer exit thread!\n"; #else timer_thread(CLS_STOP); #endif //////////////////////////////////////////////////////////////// // stop market socket listen //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start socket listen exit thread!\n"; mkt_socket_listen(CLS_STOP); cout << "Socket Listener stop thread!\n"; #else mkt_socket_listen(CLS_STOP); #endif //////////////////////////////////////////////////////////////// // stop idx socket data thread //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start socket data exit thread!\n"; idx_socket_data(CLS_STOP); cout << "socket data stop thread!\n"; #else idx_socket_data(CLS_STOP); #endif //////////////////////////////////////////////////////////////// // stop idx data manager thread //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start data manager exit thread!\n"; idx_data_manager(CLS_STOP); cout << "data manager stop thread!\n"; #else idx_data_manager(CLS_STOP); #endif //////////////////////////////////////////////////////////////// // stop market client manager thread //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start mkt client mgr exit thread!\n"; mkt_client_manager(CLS_STOP); cout << "Client Manager stop thread!\n"; #else mkt_client_manager(CLS_STOP); #endif //////////////////////////////////////////////////////////////// // stop data storage manager thread //////////////////////////////////////////////////////////////// #if defined(DEBUG) cout << "start data storage exit thread!\n"; #endif data_storage(CLS_STOP); #if defined(DEBUG) cout << "Data Storage stop thread!\n"; #endif destroy_objects(); }
void MainControl::execute_command(usr_cmd_e cmd) { switch( cmd ) { case CMD_INVALID: break; case CMD_CHANGE_DATE: on_change_date(); break; case CMD_CLEAN_UP: on_clean_up(); break; case CMD_START_UP: on_start_up(); break; case CMD_DATA_START: idx_socket_data(CLS_START); break; case CMD_DATA_STOP: idx_socket_data(CLS_STOP); break; case CMD_DATA_FINISH: idx_socket_data(CLS_STOP); break; case CMD_DATA_ERROR: { idx_socket_data(CLS_STOP); idx_socket_data(CLS_START); } break; case CMD_MKTLST_START: mkt_socket_listen(CLS_START); break; case CMD_MKTLST_STOP: mkt_socket_listen(CLS_STOP); break; case CMD_MKTLST_ERROR: { mkt_socket_listen(CLS_STOP); mkt_socket_listen(CLS_START); } break; case CMD_DTMGR_START: idx_data_manager(CLS_START); break; case CMD_DTMGR_STOP: idx_data_manager(CLS_STOP); break; case CMD_DTMGR_ERROR: { idx_data_manager(CLS_STOP); idx_data_manager(CLS_START); } break; case CMD_DTSTO_START: data_storage(CLS_START); break; case CMD_DTSTO_STOP: data_storage(CLS_STOP); break; case CMD_DTSTO_ERROR: { data_storage(CLS_STOP); data_storage(CLS_START); } break; case CMD_MKTMGR_START: mkt_client_manager(CLS_START); break; case CMD_MKTMGR_STOP: mkt_client_manager(CLS_STOP); break; case CMD_MKTMGR_ERROR: { mkt_client_manager(CLS_STOP); mkt_client_manager(CLS_START); } break; default: break; } }