• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_timer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: switch

//正常关闭RUDP SOCKET
void RUDPSocket::close()
{
    switch(state_)
    {
    case RUDP_CONNECTING:
    case RUDP_CONNECTED:
        if(event_handler_ != NULL)
        {
            event_handler_->rudp_close_event(rudp_id_);
        }

        //发送SYN
        RUDP_INFO("close rudp socket, state = RUDP_FIN_STATE, rudp id = " << rudp_id_);
        set_state(RUDP_FIN_STATE);
        
        RUDP_DEBUG("send fin, rudp socket id = " << rudp_id_);
        send_fin();
        set_timer(ccc_.get_rtt() + TIMER_MIN_DELAY);

        send_count_ ++;
        break;

    case RUDP_FIN2_STATE:
        set_state(RUDP_CLOSE);
        break;
    }
}
开发者ID:RivenZoo,项目名称:revolver,代码行数:28,代码来源:rudp_socket.cpp


示例2: main

int
main(int argc, char **argv)
{
    int ret;

    settings_init();

    if (set_signal_handler(signals) == -1) {
        return -1;
    }

    tc_time_init();

    if (read_args(argc, argv) == -1) {
        return -1;
    }

    if (srv_settings.log_path == NULL) {
        srv_settings.log_path = "error_intercept.log";  
    }

    if (tc_log_init(srv_settings.log_path) == -1) {
        return -1;
    }

    ret = tc_event_loop_init(&s_event_loop, MAX_FD_NUM);
    if (ret == TC_EVENT_ERROR) {
        tc_log_info(LOG_ERR, 0, "event loop init failed");
        return -1;
    }

    /* output debug info */
    output_for_debug();
    if (set_details() == -1) {
        return -1;
    }

    if (interception_init(&s_event_loop, srv_settings.bound_ip,
                          srv_settings.port) == TC_ERROR)
    {
        return -1;
    }

    if (set_timer() == -1) {
        return -1;
    }

#if (INTERCEPT_COMBINED)
    tc_event_timer_add(&s_event_loop, CHECK_INTERVAL, interception_push);
#endif
    tc_event_timer_add(&s_event_loop, OUTPUT_INTERVAL,
            interception_output_stat);

    /* run now */
    tc_event_process_cycle(&s_event_loop);

    server_release_resources();

    return 0;
}
开发者ID:fengwuze,项目名称:tcpcopy,代码行数:60,代码来源:main.c


示例3: vtimer_cntp_tval

static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r,
                             bool read)
{
    struct vcpu *v = current;
    s_time_t now;

    if ( !ACCESS_ALLOWED(regs, EL0PTEN) )
        return false;

    now = NOW() - v->domain->arch.phys_timer_base.offset;

    if ( read )
    {
        *r = (uint32_t)(ns_to_ticks(v->arch.phys_timer.cval - now) & 0xffffffffull);
    }
    else
    {
        v->arch.phys_timer.cval = now + ticks_to_ns(*r);
        if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE )
        {
            v->arch.phys_timer.ctl &= ~CNTx_CTL_PENDING;
            set_timer(&v->arch.phys_timer.timer,
                      v->arch.phys_timer.cval +
                      v->domain->arch.phys_timer_base.offset);
        }
    }
    return true;
}
开发者ID:Xilinx,项目名称:xen,代码行数:28,代码来源:vtimer.c


示例4: vtimer_cntp_cval

static bool vtimer_cntp_cval(struct cpu_user_regs *regs, uint64_t *r,
                             bool read)
{
    struct vcpu *v = current;

    if ( !ACCESS_ALLOWED(regs, EL0PTEN) )
        return false;

    if ( read )
    {
        *r = ns_to_ticks(v->arch.phys_timer.cval);
    }
    else
    {
        v->arch.phys_timer.cval = ticks_to_ns(*r);
        if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE )
        {
            v->arch.phys_timer.ctl &= ~CNTx_CTL_PENDING;
            set_timer(&v->arch.phys_timer.timer,
                      v->arch.phys_timer.cval +
                      v->domain->arch.phys_timer_base.offset);
        }
    }
    return true;
}
开发者ID:Xilinx,项目名称:xen,代码行数:25,代码来源:vtimer.c


示例5: main

int
main (int argc, char *argv[])
{
  sigcb (SIGALRM, wrap (timer_event));
  set_timer ();
  amain ();
}
开发者ID:Halfnhav4,项目名称:okws,代码行数:7,代码来源:tmr.C


示例6: vtimer_cntp_ctl

static bool vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, bool read)
{
    struct vcpu *v = current;

    if ( !ACCESS_ALLOWED(regs, EL0PTEN) )
        return false;

    if ( read )
    {
        *r = v->arch.phys_timer.ctl;
    }
    else
    {
        uint32_t ctl = *r & ~CNTx_CTL_PENDING;
        if ( ctl & CNTx_CTL_ENABLE )
            ctl |= v->arch.phys_timer.ctl & CNTx_CTL_PENDING;
        v->arch.phys_timer.ctl = ctl;

        if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE )
        {
            set_timer(&v->arch.phys_timer.timer,
                      v->arch.phys_timer.cval + v->domain->arch.phys_timer_base.offset);
        }
        else
            stop_timer(&v->arch.phys_timer.timer);
    }
    return true;
}
开发者ID:Xilinx,项目名称:xen,代码行数:28,代码来源:vtimer.c


示例7: switcher_led_timer

static void switcher_led_timer(void *opaque)
{
    static struct timer_t       *t = NULL;
    struct timeval              tv;
    static int                  onoff = 0;

    opaque = opaque;

    if  (onoff == 1 && (!mouse_grab_domain || !keyboard_grab_domain ||
                mouse_grab_domain == keyboard_grab_domain))
    {
        if (t)
        {
            free_timer(t);
            t = NULL;
        }
        return;
    }

    input_leds(onoff);
    onoff = !onoff;

    if (t == NULL)
        t = set_new_timer(switcher_led_timer, NULL);

    gettimeofday(&tv, NULL);
    tv.tv_usec += 500 * 1000;

    if (tv.tv_usec > 1000000) {
        tv.tv_usec -= 1000000;
        tv.tv_sec++;
    }

    set_timer(t, &tv);
}
开发者ID:eric-ch,项目名称:input,代码行数:35,代码来源:domains.c


示例8: main

int
main(int argc, char **argv) {
  extern int errno;
  int i, seconds;
  char * endptr;
  char **newargv;

  i = parse_options(argc, argv);

  errno = 0;
  seconds = (unsigned int) strtoul(argv[i], &endptr, 10);
  if (errno || &endptr[0] == argv[i])
    usage("Invalid seconds parameter\n");

  /* grab command [args ...] */
  newargv = argv + (i + 1);

  /* schedule alarm */
  if (xcpu) {
    if (rlim_cpu(seconds) == -1) {
      perror("rlimit cpu");
      exit(1);
    }
  } else {
    if (set_timer(seconds, timer_type, recur) == -1) {
      perror("setitimer");
      exit(1);
    }
  }

  execvp(newargv[0], newargv);

  perror("exec");
  exit(1);
}
开发者ID:vaishakbelle,项目名称:APPROXWMI,代码行数:35,代码来源:doalarm.c


示例9: set_lwip_timer

/*
 * Check if and when lwIP has its next timeout, and set or cancel our timer
 * accordingly.
 */
static void
set_lwip_timer(void)
{
	uint32_t next_timeout;
	clock_t ticks;

	/* Ask lwIP when the next alarm is supposed to go off, if any. */
	next_timeout = sys_timeouts_sleeptime();

	/*
	 * Set or update the lwIP timer.  We rely on set_timer() asking the
	 * kernel for an alarm only if the timeout is different from the one we
	 * gave it last time (if at all).  However, due to conversions between
	 * absolute and relative times, and the fact that we cannot guarantee
	 * that the uptime itself does not change while executing these
	 * routines, set_timer() will sometimes be issuing a kernel call even
	 * if the alarm has not changed.  Not a huge deal, but fixing this will
	 * require a different interface to lwIP and/or the timers library.
	 */
	if (next_timeout != (uint32_t)-1) {
		/*
		 * Round up the next timeout (which is in milliseconds) to the
		 * number of clock ticks to add to the current time.  Avoid any
		 * potential for overflows, no matter how unrealistic..
		 */
		if (next_timeout > TMRDIFF_MAX / sys_hz())
			ticks = TMRDIFF_MAX;
		else
			ticks = (next_timeout * sys_hz() + 999) / 1000;

		set_timer(&lwip_timer, ticks, expire_lwip_timer, 0 /*unused*/);
	} else
		cancel_timer(&lwip_timer);	/* not really needed.. */
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:38,代码来源:lwip.c


示例10: init_scheduling

void init_scheduling(void)
{
	balance_timeout = BALANCE_TIMEOUT * sys_hz();
	srandom(1000);
	init_timer(&sched_timer);
	set_timer(&sched_timer, balance_timeout, balance_queues, 0);
}
开发者ID:abdulaziz-8694,项目名称:Lottery_Scheduler_MINIX3,代码行数:7,代码来源:schedule.c


示例11: ldh_src_init

static int32_t
ldh_src_init(media_src *src)
{
    ld_src *ld = (ld_src*)src;
    ldh_src *ldh = (ldh_src*)ld;

    ld->idx[ST_VIDEO] = ST_MAX;
    ld->idx[ST_AUDIO] = ST_MAX;
    ld->ldl = 0;
    ld->break_off = 0;
    ld->u = NULL;

    ldh->state = INIT;
    ldh->flags = 0;
    INIT_LIST_HEAD(&ldh->frm_list);
    ldh->frm_count = 0;
    ldh->ldh_lock = LOCK_NEW();
    ldh->next_frame = NULL;
    ldh->err = 0;
    ldh->last_ts = 0;
    ldh->scale = 1;
    ldh->timer = set_timer(10, ldh_stm_timer, ldh_stm_timer_del, ldh);
    if (!ldh->timer)
    {
        LOCK_DEL(ldh->ldh_lock);
        return -ENOMEM;
    }

    media_src_ref(src);
    return 0;
}
开发者ID:dulton,项目名称:nampu,代码行数:31,代码来源:ldh_src.c


示例12: start_scan_sambaserver

void start_scan_sambaserver(int use_sys_timer)
{
	//- Remove all
	smb_srv_info_t *c;
	for (c = smb_srv_info_list; c; c = c->next) {
		Cdbg(DBE, "remove , ip=[%s]\n", c->ip->ptr);
		DLIST_REMOVE(smb_srv_info_list,c);
		free(c);
		c = smb_srv_info_list;
	}
	free(smb_srv_info_list);
	
	init_a_srvInfo();

	g_useSystemTimer = use_sys_timer;
	g_bInitialize = 1;
	
#ifdef _USEMYTIMER
	if(g_useSystemTimer==0){
		Cdbg(DBE, "create timer\n");
		timer_t arp_timer = create_timer(TT_SIGUSR2);
    	install_sighandler(TT_SIGUSR2, on_arpping_timer_handler);
    	set_timer(arp_timer, ARP_TIME_INTERVAL);
	}
#endif
}
开发者ID:heartshare,项目名称:asuswrt-merlin,代码行数:26,代码来源:~arpping_thread.c


示例13: logerror

void pic8259_device::set_irq_line(int irq, int state)
{
	UINT8 mask = (1 << irq);

	if (state)
	{
		/* setting IRQ line */
		if (LOG_GENERAL)
			logerror("pic8259_set_irq_line() %s: PIC set IRQ line #%d\n", tag(), irq);

		if(m_level_trig_mode || (!m_level_trig_mode && !(m_irq_lines & mask)))
		{
			m_irr |= mask;
		}
		m_irq_lines |= mask;
	}
	else
	{
		/* clearing IRQ line */
		if (LOG_GENERAL)
		{
			logerror("pic8259_device::set_irq_line() %s: PIC cleared IRQ line #%d\n", tag(), irq);
		}

		m_irq_lines &= ~mask;
		m_irr &= ~mask;
	}
	set_timer();
}
开发者ID:curtiszimmerman,项目名称:mame,代码行数:29,代码来源:pic8259.c


示例14: dotcpwatch

int dotcpwatch (int argc, char** argv, void *p)
{
    if(argc < 2)
    {
        tprintf ("TCP Watch Dog timer %d/%d seconds\n",
        	read_timer (&TcpWatchTimer)/1000,
        		dur_timer(&TcpWatchTimer)/1000);

        return 0;
    }

    stop_timer (&TcpWatchTimer);	/* in case it's already running */

	/* what to call on timeout */
    TcpWatchTimer.func = (void (*)(void*))dowatchtick;

    TcpWatchTimer.arg = NULLCHAR;	/* dummy value */

	/* set timer duration */
    set_timer (&TcpWatchTimer, (uint32)atoi (argv[1])*1000);

    start_timer (&TcpWatchTimer);	/* and fire it up */

    return 0;
}
开发者ID:mlangelaar,项目名称:jnos2,代码行数:25,代码来源:tcpwatch.c


示例15: second_clock

/*********************************
/function name: second_clock()
/function: timer
*********************************/
void second_clock()
{	
	signal(SIGALRM, signal_handler);
	set_timer();
	while(count <= 600);
	exit(0);
}
开发者ID:VincentBao,项目名称:Cloud-Computing,代码行数:11,代码来源:float.c


示例16: respawn_callback

// respawn character tmp at tmpx,tmpy
// if that place is occupied, try again in one second
static void respawn_callback(int tmp,int tmpx,int tmpy,int tmpa,int dum)
{
	int cn;

        cn=create_char_nr(tmp,tmpa);
	
	ch[cn].tmpx=tmpx;
	ch[cn].tmpy=tmpy;
	
	if (char_driver(ch[cn].driver,CDT_RESPAWN,cn,0,0)==1 && set_char(cn,tmpx,tmpy,0)) {
		
                update_char(cn);
		
		ch[cn].hp=ch[cn].value[0][V_HP]*POWERSCALE;
		ch[cn].endurance=ch[cn].value[0][V_ENDURANCE]*POWERSCALE;
		ch[cn].mana=ch[cn].value[0][V_MANA]*POWERSCALE;

		if (ch[cn].lifeshield<0) {
			elog("respawn_callback(): lifeshield=%d (%X) for char %d (%s). fixed.",ch[cn].lifeshield,ch[cn].lifeshield,cn,ch[cn].name);
			ch[cn].lifeshield=0;
		}
		
		ch[cn].dir=DX_RIGHTDOWN;

		register_respawn_respawn(cn);

		//charlog(cn,"created by respawn");
		
		return;
	}

	destroy_char(cn);

	set_timer(ticker+TICKS*10,respawn_callback,tmp,tmpx,tmpy,tmpa,0);
}
开发者ID:Bloodknight,项目名称:Astonia_Server_3.0,代码行数:37,代码来源:death.c


示例17: init_timer

static void
init_timer(int seconds)
{
	timer = CreateWaitableTimer(NULL, TRUE, NULL);
	if (timer == NULL) die("CreateWaitableTimer failed");
	set_timer(seconds);
}
开发者ID:GemikGmbH,项目名称:Corelatus-GTH-example-code,代码行数:7,代码来源:save_to_pcap.c


示例18: jpf_service_init

static __inline__ void
jpf_service_init(jpf_service *ps)
{
	memset(ps, 0, sizeof(*ps));
	ps->jpf_timer = set_timer(1000, jpf_service_timer, NULL, ps);
	BUG_ON(!ps->jpf_timer);
}
开发者ID:dulton,项目名称:nampu,代码行数:7,代码来源:jpf_service.c


示例19: pmt_timer_callback

/* This function should be called soon after each time the MSB of the
 * pmtimer register rolls over, to make sure we update the status
 * registers and SCI at least once per rollover */
static void pmt_timer_callback(void *opaque)
{
    PMTState *s = opaque;
    uint32_t pmt_cycles_until_flip;
    uint64_t time_until_flip;

    spin_lock(&s->lock);

    /* Recalculate the timer and make sure we get an SCI if we need one */
    pmt_update_time(s);

    /* How close are we to the next MSB flip? */
    pmt_cycles_until_flip = TMR_VAL_MSB - (s->pm.tmr_val & (TMR_VAL_MSB - 1));

    /* Overall time between MSB flips */
    time_until_flip = (1000000000ULL << 23) / FREQUENCE_PMTIMER;

    /* Reduced appropriately */
    time_until_flip = (time_until_flip * pmt_cycles_until_flip) >> 23;

    /* Wake up again near the next bit-flip */
    set_timer(&s->timer, NOW() + time_until_flip + MILLISECS(1));

    spin_unlock(&s->lock);
}
开发者ID:mikesun,项目名称:xen-cow-checkpointing,代码行数:28,代码来源:pmtimer.c


示例20: set_timer

/*************************************************
* Load modules                                   *
*************************************************/
void Library_State::load(Modules& modules)
   {
#ifndef BOTAN_TOOLS_ONLY
   set_timer(modules.timer());
   set_transcoder(modules.transcoder());
#endif

   std::vector<Allocator*> mod_allocs = modules.allocators();
   for(u32bit j = 0; j != mod_allocs.size(); j++)
      add_allocator(mod_allocs[j]);

   set_default_allocator(modules.default_allocator());

#ifndef BOTAN_TOOLS_ONLY
   std::vector<Engine*> mod_engines = modules.engines();
   for(u32bit j = 0; j != mod_engines.size(); ++j)
      {
      Named_Mutex_Holder lock("engine");
      engines.push_back(mod_engines[j]);
      }

   std::vector<EntropySource*> sources = modules.entropy_sources();
   for(u32bit j = 0; j != sources.size(); ++j)
      add_entropy_source(sources[j]);
#endif
   }
开发者ID:AlekSi,项目名称:Jabbin,代码行数:29,代码来源:libstate.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_title函数代码示例发布时间:2022-05-30
下一篇:
C++ set_timeout函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap