示例#1
0
void wd_trackers_init(void) {
	wd_tracker_runtime_id = wi_runtime_register_class(&wd_tracker_runtime_class);

	wd_trackers = wi_array_init(wi_mutable_array_alloc());

	wd_trackers_register_timer =
		wi_timer_init_with_function(wi_timer_alloc(),
									wd_trackers_register_with_timer,
									WD_TRACKERS_REGISTER_INTERVAL,
									true);
	
	wd_trackers_update_timer =
		wi_timer_init_with_function(wi_timer_alloc(),
									wd_trackers_update_with_timer,
									WD_TRACKERS_UPDATE_INTERVAL,
									true);
}
示例#2
0
void wd_init_transfers(void) {
	wd_transfer_runtime_id = wi_runtime_register_class(&wd_transfer_runtime_class);

	wd_transfers = wi_list_init(wi_list_alloc());

	wd_transfers_timer = wi_timer_init_with_function(wi_timer_alloc(),
													 wd_update_transfers,
													 WD_TRANSFERS_TIMER_INTERVAL,
													 true);
}
示例#3
0
static void wd_transfer_create_timer(wd_transfer_t *transfer) {
	transfer->timer = wi_timer_init_with_function(wi_timer_alloc(),
												  wd_transfer_expire_timer,
												  WD_TRANSFERS_WAITING_INTERVAL,
												  false);
	wi_timer_set_data(transfer->timer, transfer);
	wi_timer_schedule(transfer->timer);
	
	wi_retain(transfer);
}
示例#4
0
文件: users.c 项目: ProfDrLuigi/zanka
void wd_users_init(void) {
	wd_user_runtime_id = wi_runtime_register_class(&wd_user_runtime_class);

	wd_users = wi_dictionary_init(wi_dictionary_alloc());
	
	wd_users_uid_lock = wi_lock_init(wi_lock_alloc());
		
	wd_users_timer = wi_timer_init_with_function(wi_timer_alloc(),
												 wd_users_update_idle,
												 WD_USERS_TIMER_INTERVAL,
												 true);
}
示例#5
0
void wt_init_servers(void) {
	wt_server_runtime_id = wi_runtime_register_class(&wt_server_runtime_class);

	wt_servers = wi_list_init(wi_list_alloc());
	
	wt_servers_lock = wi_lock_init(wi_lock_alloc());

	wt_servers_timer = wi_timer_init_with_function(wi_timer_alloc(),
												   wt_update_servers,
												   WT_SERVERS_UPDATE_INTERVAL,
												   true);
}
示例#6
0
void wi_test_timer(void) {
#ifdef WI_PTHREADS
    wi_timer_t		*timer;

    timer = wi_autorelease(wi_timer_init_with_function(wi_timer_alloc(), _wi_test_timer_function, 0.01, false));
    wi_timer_set_data(timer, &_wi_test_timer_hits);
    wi_timer_schedule(timer);

    wi_thread_sleep(0.1);

    WI_TEST_ASSERT_EQUALS(_wi_test_timer_hits, 5U, "");
#endif
}
示例#7
0
void wd_banlist_add_temporary_ban_for_ip(wi_string_t *ip) {
	wd_tempban_t	*tempban;
	
	tempban = wd_tempban_with_ip(ip);
	tempban->timer = wi_timer_init_with_function(wi_timer_alloc(),
										wd_tempban_expire_timer,
										wd_settings.bantime,
										false);

	wi_timer_set_data(tempban->timer, tempban);
	wi_timer_schedule(tempban->timer);
	
	wi_dictionary_wrlock(wd_tempbans);
	wi_mutable_dictionary_set_data_for_key(wd_tempbans, tempban, tempban->ip);
	wi_dictionary_unlock(wd_tempbans);
}
示例#8
0
void wi_test_timer(void) {
#ifdef WI_PTHREADS
	wi_timer_t		*timer;
	
	_wi_test_timer_lock = wi_autorelease(wi_condition_lock_init_with_condition(wi_condition_lock_alloc(), 0));
	
	timer = wi_autorelease(wi_timer_init_with_function(wi_timer_alloc(), _wi_test_timer_function, 0.001, false));
	wi_timer_schedule(timer);
	
	if(wi_condition_lock_lock_when_condition(_wi_test_timer_lock, 1, 1.0)) {
		WI_TEST_ASSERT_EQUALS(_wi_test_timer_hits, 5U, "");
		wi_condition_lock_unlock(_wi_test_timer_lock);
	} else {
		WI_TEST_FAIL("Timed out waiting for timer, currently at %u %s",
			_wi_test_timer_hits, _wi_test_timer_hits == 1 ? "hit" : "hits");
	}
#endif
}