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


C++ set_timer函数代码示例

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


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


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