本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例5: main
int
main (int argc, char *argv[])
{
sigcb (SIGALRM, wrap (timer_event));
set_timer ();
amain ();
}
示例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;
}
示例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);
}
示例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);
}
示例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.. */
}
示例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);
}
示例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;
}
示例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
}
示例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();
}
示例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;
}
示例15: second_clock
/*********************************
/function name: second_clock()
/function: timer
*********************************/
void second_clock()
{
signal(SIGALRM, signal_handler);
set_timer();
while(count <= 600);
exit(0);
}