tb_void_t tb_exit() { // need exit? tb_long_t init = 0; if ((init = tb_atomic_dec_and_fetch(&g_init)) > 0) return ; // check tb_assert_and_check_return(!init); // kill singleton tb_singleton_kill(); // exit object #ifdef TB_CONFIG_MODULE_HAVE_OBJECT tb_object_context_exit(); #endif // exit network tb_network_exit(); // exit libm tb_libm_exit(); // exit math tb_math_exit(); // exit libc tb_libc_exit(); // exit platform tb_platform_exit(); // exit singleton tb_singleton_exit(); // exit memory tb_memory_exit(); // trace tb_trace_d("exit: ok"); // exit trace tb_trace_exit(); }
tb_void_t tb_exit() { // have been exited? if (TB_STATE_OK != tb_atomic_fetch_and_pset(&g_state, TB_STATE_OK, TB_STATE_EXITING)) return ; // kill singleton tb_singleton_kill(); // exit object #ifdef TB_CONFIG_MODULE_HAVE_OBJECT tb_object_exit_env(); #endif // exit network envirnoment tb_network_exit_env(); // exit libm envirnoment tb_libm_exit_env(); // exit math envirnoment tb_math_exit_env(); // exit libc envirnoment tb_libc_exit_env(); // exit platform envirnoment tb_platform_exit_env(); // exit singleton tb_singleton_exit(); // exit memory envirnoment tb_memory_exit_env(); // trace tb_trace_d("exit: ok"); // exit trace tb_trace_exit(); // end tb_atomic_set(&g_state, TB_STATE_END); }