当前位置: 首页>>代码示例>>C++>>正文


C++ register_timer函数代码示例

本文整理汇总了C++中register_timer函数的典型用法代码示例。如果您正苦于以下问题:C++ register_timer函数的具体用法?C++ register_timer怎么用?C++ register_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了register_timer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: log_putc

int log_putc(int c)
{
	if(last_update.trigger_value == 0)
		last_update = register_timer(LOG_TIMEOUT);

	if(log_buf && buf_size)
	{
		log_buf[buf_ptr++] = c;
		if(buf_ptr >= buf_size)
		{
			if(log_fp && log_fp->fflush_cb)
			{
				log_fp->fflush_cb(log_fp);
				last_update = register_timer(LOG_TIMEOUT);
			}
			buf_ptr = 0;
		}
		return 0;
	}
	else if(log_fp)
	{
		// Disable output to the log for the write
		rpi_boot_output_state state = output_get_state();
		output_disable_log();

		// Write one character
		fwrite(&c, 1, 1, log_fp);

		// Restore saved output state
		output_restore_state(state);
		return 0;
	}
	return EOF;
}
开发者ID:jncronin,项目名称:rpi-boot,代码行数:34,代码来源:log.c

示例2: mod_init

static int mod_init(void)
{
	LM_INFO("Call Center module - initializing\n");

	init_db_url( db_url , 0 /*cannot be null*/);
	init_db_url( acc_db_url , 0 /*cannot be null*/);
	b2b_scenario.len = strlen(b2b_scenario.s);

	/* Load B2BUA API */
	if (load_b2b_logic_api( &b2b_api) != 0) {
		LM_ERR("Can't load B2B-UA hooks, missing 'b2b_logic' module ?\n");
		return -1;
	}

	if (register_timer( "cc_agents", cc_timer_agents, NULL, 1)<0) {
		LM_ERR("failed to register agents timer function\n");
		return -1;
	}

	if (register_timer( "cc_cleanup", cc_timer_cleanup, NULL, 5)<0) {
		LM_ERR("failed to register cleaup timer function\n");
		return -1;
	}

	/* main CC data */
	data = init_cc_data();
	if (data==0) {
		LM_CRIT("failed to get shm mem for data\n");
		return -1;
	}

	/* init and open DB connection */
	if (init_cc_db( &db_url )!=0) {
		LM_ERR("failed to initialize the DB support\n");
		return -1;
	}
	if (init_cc_acc_db( &acc_db_url )!=0) {
		LM_ERR("failed to initialize the acc DB support\n");
		return -1;
	}

	/* load data */
	if ( cc_load_db_data( data )!=0 ) {
		LM_CRIT("failed to load callcenter data\n");
		return -1;
	}
	clean_cc_old_data(data);

	/* restore calls */
	if ( cc_db_restore_calls( data )!=0 ) {
		LM_CRIT("failed to load callcenter data\n");
		return -1;
	}

	/* close DB connection */
	cc_close_db();

	return 0;
}
开发者ID:abh-gitcs1989,项目名称:opensips,代码行数:59,代码来源:call_center.c

示例3: mod_init

/**
 * init module function
 */
static int mod_init(void)
{
	stm_timer_t *it;
	if(_stm_list==NULL)
		return 0;

	/* init faked sip msg */
	if(faked_msg_init()<0)
	{
		LM_ERR("failed to init timer local sip msg\n");
		return -1;
	}

	/* register timers */
	it = _stm_list;
	while(it)
	{
		if(it->mode==0)
		{
			if(register_timer(stm_timer_exec, (void*)it, it->interval)<0)
			{
				LM_ERR("failed to register timer function\n");
				return -1;
			}
		} else {
			register_basic_timers(1);
		}
		it = it->next;
	}

	return 0;
}
开发者ID:aallamaa,项目名称:kamailio,代码行数:35,代码来源:rtimer_mod.c

示例4: mod_init

static int mod_init(void)
{
	LM_INFO("initializing SMPP protocol\n");

	db_url.len = strlen(db_url.s);
	smpp_outbound_uri.len = strlen(smpp_outbound_uri.s);

	if (smpp_db_init(&db_url) < 0)
		return -1;

	if (smpp_sessions_init() < 0)
		return -1;

	smpp_db_close();

	if (register_timer("enquire-link-timer", enquire_link, NULL, 5,
			TIMER_FLAG_DELAY_ON_DELAY)<0 )
		return -1;

	/* load the TM API */
	if (load_tm_api(&tmb)!=0) {
		LM_ERR("can't load TM API\n");
		return -1;
	}


	return 0;
}
开发者ID:rrb3942,项目名称:opensips,代码行数:28,代码来源:proto_smpp.c

示例5: get_cpu_info

void get_cpu_info(unsigned long arg)
{
	unsigned int i;
	unsigned int frequency;
	cputime64_t curr_idle_time, curr_wall_time;
	unsigned int delta_wall_time, delta_idle_time;
	unsigned int cpu_load;
	
	struct cpu_monitor_info_s *pdata = (struct cpu_monitor_info_s *)arg;

	/* CPU frequency */
	frequency = cpufreq_quick_get(0);
	printk("[Monitor] cpu frequency: %u\n", frequency);

	for(i=0; i<NUM_CPUS; ++i)
	{
		/* CPU load */
		curr_idle_time = get_cpu_idle_time_us(i, &curr_wall_time);
		delta_wall_time = (unsigned int) cputime64_sub(curr_wall_time, 
				pdata->cpu_info[i].prev_cpu_wall);
		pdata->cpu_info[i].prev_cpu_wall = curr_wall_time;

		delta_idle_time = (unsigned int) cputime64_sub(curr_idle_time, 
				pdata->cpu_info[i].prev_cpu_idle);
		pdata->cpu_info[i].prev_cpu_idle = curr_idle_time;

		cpu_load = 100*(delta_wall_time - delta_idle_time)/delta_wall_time;
		if(cpu_load>100)	cpu_load=0;
		printk("[Monitor] cpu %u load: %u\n", i, cpu_load);
	}
	
	if(g_counter<10)
		register_timer(pdata, TIME_STEP);
}
开发者ID:again4you,项目名称:private,代码行数:34,代码来源:monitor.c

示例6: initialize_kill

int initialize_kill(void)
{
	/* if disabled ... */
	if (time_to_kill == 0)
		return 0;

	if (register_timer("exec_kill", timer_routine, NULL /* param */,
	    1 /* period */, TIMER_FLAG_SKIP_ON_DELAY) < 0) {
		LM_ERR("no exec timer registered\n");
		return -1;
	}

	kill_list = shm_malloc(sizeof *kill_list);
	if (!kill_list) {
		LM_ERR("no more shm!\n");
		return -1;
	}

	kill_list->first_tl.next_tl = &kill_list->last_tl;
	kill_list->last_tl.prev_tl  = &kill_list->first_tl;
	kill_list->first_tl.prev_tl =
	kill_list->last_tl.next_tl  = NULL;

	kill_list->last_tl.time_out = -1;

	kill_lock = lock_alloc();
	if (!kill_lock) {
		LM_ERR("no shm mem for mutex\n");
		return -1;
	}
	lock_init(kill_lock);

	LM_DBG("kill initialized\n");
	return 0;
}
开发者ID:dsanders11,项目名称:opensips,代码行数:35,代码来源:kill.c

示例7: mod_init

static int
mod_init(void)
{
    bind_usrloc_t ul_bind_usrloc;

    if (natpingInterval > 0) {
        ul_bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
        if (!ul_bind_usrloc) {
            LOG(L_ERR, "error: mediaproxy/mod_init(): can't find the usrloc "
                "module. Check if usrloc.so is loaded.\n");
            return -1;
        }

        if (ul_bind_usrloc(&userLocation) < 0) {
            LOG(L_ERR, "error: mediaproxy/mod_init(): can't access the usrloc module.\n");
            return -1;
        }

        register_timer(pingClients, NULL, natpingInterval);
    }

    checkAsymmetricFile(&sipAsymmetrics);
    checkAsymmetricFile(&rtpAsymmetrics);

    // children won't benefit from this. figure another way
    //register_timer(checkAsymmetricFiles, NULL, 5);

    return 0;
}
开发者ID:BackupTheBerlios,项目名称:openimscore-svn,代码行数:29,代码来源:mediaproxy.c

示例8: mod_init

/**
 * init module function
 */
static int mod_init(void)
{
	load_tm_f  load_tm;

	DBG("MSILO: initializing ...\n");

	/* binding to mysql module  */
	if (bind_dbmod())
	{
		DBG("MSILO: ERROR: Database module not found\n");
		return -1;
	}

	/* import the TM auto-loading function */
	if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {
		LOG(L_ERR, "ERROR: msilo: mod_init: can't import load_tm\n");
		return -1;
	}
	/* let the auto-loading function load all TM stuff */
	if (load_tm( &tmb )==-1)
		return -1;

	ml = msg_list_init();
	if(!ml)
	{
		DBG("ERROR: msilo: mod_init: can't initialize msg list\n");
		return -1;
	}
	register_timer( m_clean_silo, 0, check_time);

	reg_addr.s = registrar;
	reg_addr.len = (registrar)?strlen(registrar):0;

	return 0;
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:38,代码来源:msilo.c

示例9: register_functions

void register_functions( lua_State* L, gwlua_t* state )
{
  static const luaL_Reg statics[] =
  {
    { "playsound",     l_playsound },
    { "stopsounds",    l_stopsounds },
    { "randomize",     l_randomize },
    { "random",        l_random },
    { "round",         l_round },
    { "now",           l_now },
    { "splittime",     l_splittime },
    { "inttostr",      l_inttostr },
    { "loadvalue",     l_loadvalue },
    { "savevalue",     l_savevalue },
    { "setbackground", l_setbackground },
    { "setzoom",       l_setzoom },
    { "inputstate",    l_inputstate },
    { "loadbin",       l_loadbin },
    { "loadbs",        l_loadbs },
    { NULL, NULL }
  };
  
  lua_newtable( L );
  
  register_image( L, state );
  register_sound( L, state );
  register_timer( L, state );
  
  lua_pushlightuserdata( L, (void*)state );
  luaL_setfuncs( L, statics, 1 );
  
  // module
  
  if ( luaL_loadbufferx( L, (const char*)gwlua_lua_system_lua, gwlua_lua_system_lua_len, "system.lua", "t" ) != LUA_OK )
  {
    lua_error( L );
    return;
  }
  
  // module chunk
  
  lua_call( L, 0, 1 );
  
  // module function
  
  lua_pushvalue( L, -2 );
  
  // module function module
  
  lua_call( L, 1, 0 );
  
  // module
  
  lua_setglobal( L, "system" );
  
  // --
}
开发者ID:kurumushi,项目名称:gw-libretro,代码行数:57,代码来源:functions.c

示例10: window_load

static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  render_layer = layer_create(bounds);
  layer_set_update_proc(render_layer, update_display);
  layer_add_child(window_layer, render_layer);
  register_timer(NULL);
}
开发者ID:franc0is,项目名称:pebble-tinymath,代码行数:9,代码来源:fractal_tree.c

示例11: repl_prof_init

int repl_prof_init(void)
{
	int index;

	if (!repl_prof_dests_nr)
		return 0;

	if (repl_prof_utimer < 0) {
		LM_ERR("negative replicate timer for profiles %d\n", repl_prof_utimer);
		return -1;
	}
	if (repl_prof_timer_check < 0) {
		LM_ERR("negative replicate timer for profiles check %d\n",
				repl_prof_timer_check);
		return -1;
	}

	if (repl_prof_timer_expire < 0) {
		LM_ERR("negative replicate expire timer for profiles %d\n",
				repl_prof_timer_expire);
		return -1;
	}

	if (repl_prof_buffer_th < 0) {
		LM_ERR("negative replicate buffer threshold for profiles %d\n",
				repl_prof_buffer_th);
		return -1;
	}

	if (register_utimer("dialog-repl-profiles-utimer", repl_prof_utimer_f, NULL,
			repl_prof_utimer * 1000, TIMER_FLAG_DELAY_ON_DELAY) < 0) {
		LM_ERR("failed to register profiles utimer\n");
		return -1;
	}
	if (register_timer("dialog-repl-profiles-timer", repl_prof_timer_f, NULL,
			repl_prof_timer_check, TIMER_FLAG_DELAY_ON_DELAY) < 0) {
		LM_ERR("failed to register profiles utimer\n");
		return -1;
	}

	if (repl_prof_buffer_th > (BUF_SIZE * 0.9)) {
		LM_WARN("Buffer size too big %d - profiles information might get lost",
				repl_prof_buffer_th);
		return -1;
	}

	/* alocate the last_message counter in shared memory */
	for (index = 0; index < repl_prof_dests_nr; index++) {
		repl_prof_dests[index].last_msg = shm_malloc(sizeof(time_t));
		if (!repl_prof_dests[index].last_msg) {
			LM_ERR("OOM shm\n");
			return -1;
		}
	}

	return 0;
}
开发者ID:ionel-cerghit,项目名称:opensips,代码行数:57,代码来源:dlg_replication.c

示例12: mod_init

/**
 * init module function
 */
static int mod_init(void)
{
	bind_xcap_t bind_xcap;
	xcap_api_t xcap_api;

        /* load XCAP API */
        bind_xcap = (bind_xcap_t)find_export("bind_xcap", 1, 0);
        if (!bind_xcap)
        {
                LM_ERR("Can't bind xcap\n");
                return -1;
        }

        if (bind_xcap(&xcap_api) < 0)
        {
                LM_ERR("Can't bind xcap\n");
                return -1;
        }
        xcap_db_url = xcap_api.db_url;
        xcap_db_table = xcap_api.xcap_table;

	/* binding to mysql module  */
	if (db_bind_mod(&xcap_db_url, &xcap_dbf))
	{
		LM_ERR("Database module not found\n");
		return -1;
	}

	if (!DB_CAPABILITY(xcap_dbf, DB_CAP_ALL)) {
		LM_ERR("Database module does not implement all functions"
				" needed by the module\n");
		return -1;
	}

	xcap_db = xcap_dbf.init(&xcap_db_url);
	if (!xcap_db)
	{
		LM_ERR("while connecting to database\n");
		return -1;
	}

	curl_global_init(CURL_GLOBAL_ALL);

	if(periodical_query)
	{
		register_timer("xcapc-update", query_xcap_update, 0,
			query_period, TIMER_FLAG_DELAY_ON_DELAY);
	}

	if(xcap_db)
		xcap_dbf.close(xcap_db);
	xcap_db = NULL;

	return 0;
}
开发者ID:alias-neo,项目名称:opensips,代码行数:58,代码来源:xcap_client.c

示例13: mod_init

/**
 * init module function
 */
static int mod_init(void)
{
	if(register_mi_mod(exports.name, mi_cmds)!=0)
	{
		LM_ERR("failed to register MI commands\n");
		return -1;
	}
	if(htable_init_rpc()!=0)
	{
		LM_ERR("failed to register RPC commands\n");
		return -1;
	}

	if(ht_init_tables()!=0)
		return -1;
	ht_db_init_params();

	if(ht_db_url.len>0)
	{
		if(ht_db_init_con()!=0)
			return -1;
		if(ht_db_open_con()!=0)
			return -1;
		if(ht_db_load_tables()!=0)
		{
			ht_db_close_con();
			return -1;
		}
		ht_db_close_con();
	}
	if(ht_has_autoexpire())
	{
		LM_DBG("starting auto-expire timer\n");
		if(ht_timer_interval<=0)
			ht_timer_interval = 20;
		if(ht_timer_procs<=0) {
			if(register_timer(ht_timer, 0, ht_timer_interval)<0)
			{
				LM_ERR("failed to register timer function\n");
				return -1;
			}
		} else {
			register_sync_timers(ht_timer_procs);
		}
	}

	if (ht_enable_dmq>0 && ht_dmq_initialize()!=0) {
		LM_ERR("failed to initialize dmq integration\n");
		return -1;
	}

	ht_iterator_init();

	return 0;
}
开发者ID:aphistic,项目名称:kamailio,代码行数:58,代码来源:htable.c

示例14: mod_init

/** Module init function */
static int mod_init(void)
{
	if(load_uac_auth_api(&uac_auth_api)<0){
		LM_ERR("Failed to load uac_auth api\n");
		return -1;
	}

	/* load all TM stuff */
	if(load_tm_api(&tmb)==-1) {
		LM_ERR("can't load tm functions\n");
		return -1;
	}

	if(default_expires<15){
		LM_ERR("default_expires to short: [%d]<15\n", default_expires);
		return -1;
	}
	if(timer_interval<10){
		LM_ERR("timer_interval to short: [%d]<10\n", timer_interval);
		return -1;
	}
	if(reg_hsize<1 || reg_hsize>20) {
		LM_ERR("Wrong hash size: 20<[%d]<1\n", reg_hsize);
	}
	reg_hsize = 1<<reg_hsize;

	if(init_reg_htable()<0) {
		LM_ERR("Failed to initialize registrant hash table\n");
		return -1;
	}

	reg_table_name.len = strlen(reg_table_name.s);
	registrar_column.len = strlen(registrar_column.s);
	proxy_column.len = strlen(proxy_column.s);
	aor_column.len = strlen(aor_column.s);
	third_party_registrant_column.len =
		strlen(third_party_registrant_column.s);
	username_column.len = strlen(username_column.s);
	password_column.len = strlen(password_column.s);
	binding_URI_column.len = strlen(binding_URI_column.s);
	binding_params_column.len = strlen(binding_params_column.s);
	expiry_column.len = strlen(expiry_column.s);
	forced_socket_column.len = strlen(forced_socket_column.s);
	init_db_url(db_url , 0 /*cannot be null*/);
	if (init_reg_db(&db_url) != 0) {
		LM_ERR("failed to initialize the DB support\n");
		return -1;
	}

	register_timer("uac_reg_check", timer_check, 0,
					timer_interval/reg_hsize);

	return 0;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:55,代码来源:registrant.c

示例15: repl_prof_init

int repl_prof_init(void)
{
	if (!profile_replicate_cluster && !accept_repl_profiles)
		return 0;

	if (repl_prof_timer_check < 0) {
		LM_ERR("negative replicate timer for profiles check %d\n",
			repl_prof_timer_check);
		return -1;
	}

	if (repl_prof_timer_expire < 0) {
		LM_ERR("negative replicate expire timer for profiles %d\n",
			repl_prof_timer_expire);
		return -1;
	}

	if (register_timer("dialog-repl-profiles-timer", repl_prof_timer_f, NULL,
		repl_prof_timer_check, TIMER_FLAG_DELAY_ON_DELAY) < 0) {
		LM_ERR("failed to register profiles utimer\n");
		return -1;
	}

	if (!profile_replicate_cluster)
		return 0;

	if (repl_prof_utimer < 0) {
		LM_ERR("negative replicate timer for profiles %d\n", repl_prof_utimer);
		return -1;
	}

	if (repl_prof_buffer_th < 0) {
		LM_ERR("negative replicate buffer threshold for profiles %d\n",
			repl_prof_buffer_th);
		return -1;
	}

	if (register_utimer("dialog-repl-profiles-utimer", repl_prof_utimer_f, NULL,
		repl_prof_utimer * 1000, TIMER_FLAG_DELAY_ON_DELAY) < 0) {
		LM_ERR("failed to register profiles utimer\n");
		return -1;
	}


	if (repl_prof_buffer_th > (BUF_SIZE * 0.9)) {
		LM_WARN("Buffer size too big %d - profiles information might get lost",
			repl_prof_buffer_th);
		return -1;
	}

	return 0;
}
开发者ID:SimleCat,项目名称:opensips,代码行数:52,代码来源:dlg_replication.c


注:本文中的register_timer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。