int main(int argc, char *argv[]) { struct timespec_t ts; if(argc <= 1) { fprintf(stderr, "error: no timespec specified (use -h for help)\n"); help(stderr, argv[0]); } memset(&ts, 0, sizeof(struct timespec_t)); if(parse_options(argc, argv) != 0) { return 1; } if(parse_timespec(optind, argc, argv, &ts) != 0) { return 2; } if(create_alarm(&ts) != 0) { return 3; } if(do_suspend(suspend_cmd ? suspend_cmd : SUSPEND_COMMAND) != 0) { return 4; } pthread_exit(NULL); return EXIT_SUCCESS; }
static void start_hs_wake_timer(void) { if(g_hs_wake_timer == 0) { g_hs_wake_timer = create_alarm(hs_wake_timer_fn, 0, NULL); } start_alarm(g_hs_wake_timer, HS_WAKE_INTERVAL); }
void process_all_events(void) { TROUT_FUNC_ENTER; if(reset_mac_trylock() == 0) { return; } atomic_set(&g_event_cnt, get_total_num_pending_events()); stop_alarm(g_mac_event_timer); while(atomic_read(&g_event_cnt) > 0) { #ifdef TROUT_WIFI_POWER_SLEEP_ENABLE #ifdef WIFI_SLEEP_POLICY if (mutex_is_locked(&suspend_mutex) || (g_wifi_suspend_status != wifi_suspend_nosuspend)) { //libing, 20140114, fix fake connection pr_info("We can't do %s during suspending, g_wifi_suspend_status = %d\n", __func__, g_wifi_suspend_status); reset_mac_unlock(); return; } #endif #endif /* Process pending events in the event queues */ process_event_queues(); if (counter_tmpr++ > 100)//by lihua { counter_tmpr = 0; #ifdef WAKE_LOW_POWER_POLICY if(g_wifi_power_mode != WIFI_NORMAL_POWER_MODE) { pr_info("We can't do %s during low power mode, g_wifi_suspend_status = %d\n", __func__, g_wifi_suspend_status); break; } #endif tempr_compensated(); } #ifndef MAC_HW_UNIT_TEST_MODE /* Handle lack of memory for WLAN Rx packets */ // handle_rxq_replenishment(); #endif /* MAC_HW_UNIT_TEST_MODE */ #ifdef BSS_ACCESS_POINT_MODE #ifdef ENABLE_PS_PKT_FLUSH /* Find the STA with maximum PS buffers */ find_max_ps_ae(); #endif /* ENABLE_PS_PKT_FLUSH */ #endif /* BSS_ACCESS_POINT_MODE */ #ifdef INT_WPS_SUPP //wxb add #ifdef IBSS_BSS_STATION_MODE /* Handle scan request from user/protocol */ if(g_wps_scan_req_from_user == BTRUE)// caisf add for fix wps scan bug. 1121 { handle_start_scan_req();//may be reset_mac g_wps_scan_req_from_user = BFALSE; } #endif #endif /* ifdef INT_WPS_SUPP */ /* Service Watchdog */ service_wdt(); } //chenq add 2012-11-02 // if((BOOL_T)atomic_read(&g_mac_reset_done) == BFALSE) //shield by chengwg, 2013-01-11! // return; /* Handle system error due to any failure */ active_netif_queue(); //add by chengwg. handle_system_error();//may be reset_mac /* Handle scan request from user/protocol */ //chenq mask 2012-10-29 //handle_start_scan_req(); #ifdef INT_WPS_SUPP //wxb add #ifdef IBSS_BSS_STATION_MODE /* Handle scan request from user/protocol */ if(g_wps_scan_req_from_user == BTRUE)// caisf add for fix wps scan bug. 1121 { handle_start_scan_req(); //the function may be reset_mac g_wps_scan_req_from_user = BFALSE; } #endif #endif /* ifdef INT_WPS_SUPP */ /* Service Watchdog */ service_wdt(); if(get_total_num_pending_events() > 0) { if(g_mac_event_timer == NULL) { g_mac_event_timer = create_alarm(mac_time2event_work, 0, NULL); } start_alarm(g_mac_event_timer, 100); } reset_mac_unlock(); TRACE_FUNC_EXIT; }
std::unique_ptr<mir::time::Alarm> mir::GLibMainLoop::create_alarm( std::function<void()> const& callback) { return create_alarm(std::make_shared<BasicCallback>(callback)); }