本文整理汇总了C++中reset_timer函数的典型用法代码示例。如果您正苦于以下问题:C++ reset_timer函数的具体用法?C++ reset_timer怎么用?C++ reset_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset_timer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_NPCs
void update_NPCs( NPC** _NPCs, int _NPCCount, bomb* _pBomb, map* _pMap )
{
// loop through all NPCs
int i;
for ( i = 0; i < _NPCCount; i++ )
{
// update NPC's coordinates atributes
_NPCs[i]->right = _NPCs[i]->left + GC_block_size;
_NPCs[i]->bottom = _NPCs[i]->top + GC_block_size;
_NPCs[i]->i = ( ( (_NPCs[i]->top + GC_block_size/2) - GC_y_offset) / GC_block_size );
_NPCs[i]->j = ( (_NPCs[i]->left + GC_block_size/2) / GC_block_size );
// invoke NPC's artificial intelligence, but not every loop
// delay the artificial intelligence, it mustn't run each loop
if ( time_is_up( _NPCs[i]->AI_timer ) )
{
//_NPCs[i]->p_NPC_AI( _pGame );
NPC_random_walk_AI( _NPCs[i], _pBomb, _NPCs, _NPCCount, _pMap );
reset_timer( _NPCs[i]->AI_timer );
}
else
{
// delay the NPC's walk
if ( time_is_up( _NPCs[i]->walk_timer ) )
{
NPC_walk( _NPCs[i], _pBomb, _NPCs, _NPCCount, _pMap, _NPCs[i]->direction );
reset_timer( _NPCs[i]->walk_timer );
}
}
}
}
示例2: main
int main(int argc, const char * argv[]){
clock_t begin = clock();
if(argc == 1){
// standard mode
mpz_t numbers[NUMBERS];
list * calculatedFactors[NUMBERS];
int i;
mpz_t y;
mpz_init_set_ui(y, 1);
for (i = 0; i < NUMBERS; i++){
mpz_init(numbers[i]);
mpz_inp_str(numbers[i], stdin, 10);
}
for (i = 0; i < NUMBERS; i++) {
reset_timer();
list* factors = createList();
factorize(factors, numbers[i],1, y);
calculatedFactors[i] = factors;
}
for (i = 0; i < NUMBERS; i++){
printFactors(calculatedFactors[i]);
}
clock_t end = clock();
double tdiff = (((double) end) - ((double)begin)) / CLOCKS_PER_SEC;
printf(", %f\n", tdiff);
return 0;
} else if(strcmp(argv[1], "interactive") == 0){
// interactive mode
fprintf(stderr, "Interactive mode!\n");
mpz_t number;
mpz_init(number);
list * factors = NULL;
mpz_t y;
mpz_init_set_ui(y, 1);
while (1) {
mpz_inp_str(number, stdin, 10);
reset_timer();
factors = createList();
factorize(factors, number, 1, y);
TRACE("PRINTING FACTORS:\n");
printFactors(factors);
}
return 0;
}
return 1;
}
示例3: cancel_invite
void cancel_invite(struct sip_msg *cancel_msg,
struct cell *t_cancel, struct cell *t_invite )
{
#define CANCEL_REASON_SIP_487 \
"Reason: SIP;cause=487;text=\"ORIGINATOR_CANCEL\"" CRLF
branch_bm_t cancel_bitmap;
branch_bm_t dummy_bm;
str reason;
unsigned int i;
struct hdr_field *hdr;
cancel_bitmap=0;
/* send back 200 OK as per RFC3261 */
reason.s = CANCELING;
reason.len = sizeof(CANCELING)-1;
t_reply( t_cancel, cancel_msg, 200, &reason );
reason.s = NULL;
reason.len = 0;
/* propagate the REASON flag ? */
if ( t_cancel->flags&T_CANCEL_REASON_FLAG ) {
/* look for the Reason header */
if (parse_headers(cancel_msg, HDR_EOH_F, 0)<0) {
LM_ERR("failed to parse all hdrs - ignoring Reason hdr\n");
} else {
hdr = get_header_by_static_name(cancel_msg, "Reason");
if (hdr!=NULL) {
reason.s = hdr->name.s;
reason.len = hdr->len;
}
}
}
/* if no reason, use NORMAL CLEARING */
if (reason.s == NULL) {
reason.s = CANCEL_REASON_SIP_487;
reason.len = sizeof(CANCEL_REASON_SIP_487) - 1;
}
/* generate local cancels for all branches */
which_cancel(t_invite, &cancel_bitmap );
set_cancel_extra_hdrs( reason.s, reason.len);
cancel_uacs(t_invite, cancel_bitmap );
set_cancel_extra_hdrs( NULL, 0);
/* internally cancel branches with no received reply */
for (i=t_invite->first_branch; i<t_invite->nr_of_outgoings; i++) {
if (t_invite->uac[i].last_received==0){
/* reset the "request" timers */
reset_timer(&t_invite->uac[i].request.retr_timer);
reset_timer(&t_invite->uac[i].request.fr_timer);
LOCK_REPLIES( t_invite );
relay_reply(t_invite,FAKED_REPLY,i,487,&dummy_bm);
}
}
}
示例4: cleanup_localcancel_timers
void cleanup_localcancel_timers( struct cell *t )
{
int i;
for (i=0; i<t->nr_of_outgoings; i++ ) {
reset_timer( &t->uac[i].local_cancel.retr_timer );
reset_timer( &t->uac[i].local_cancel.fr_timer );
}
}
示例5: cleanup_uac_timers
void cleanup_uac_timers( struct cell *t )
{
int i;
/* reset FR/retransmission timers */
for (i=t->first_branch; i<t->nr_of_outgoings; i++ ) {
reset_timer( &t->uac[i].request.retr_timer );
reset_timer( &t->uac[i].request.fr_timer );
}
LM_DBG("RETR/FR timers reset\n");
}
示例6: t_release_transaction
/* returns 1 if everything was OK or -1 for error
*/
int t_release_transaction( struct cell *trans )
{
set_kr(REQ_RLSD);
reset_timer( & trans->uas.response.fr_timer );
reset_timer( & trans->uas.response.retr_timer );
cleanup_uac_timers( trans );
put_on_wait( trans );
return 1;
}
示例7: hw_platform_start_led_blink
/**
* @brief 开始LED闪烁指示
* @param[in] unsigned int led
* @param[in] unsigned short delay 闪烁的时间间隔,也就是闪烁频率,单位10ms
* @note 注意此接口可以让几个LED同时按照各自不同的频率闪烁
*/
void hw_platform_start_led_blink(unsigned int led,unsigned short delay)
{
int ret;
hw_platform_led_ctrl(led,1);
if (led == LED_RED)
{
if (current_led_state & LED_RED_ON_MASK)
{
current_led_state |= LED_RED_MASK;
ret = reset_timer(led_timer_h[0],V_TIMER_MODE_PERIODIC,delay*10,led_red_blink_timer_hook);
assert(ret == 0);
}
else
{
current_led_state |= (LED_RED_MASK | LED_RED_ON_MASK);
led_timer_h[0] = start_timer(V_TIMER_MODE_PERIODIC,delay*10,led_red_blink_timer_hook);
assert(led_timer_h[0] != 0);
}
}
else if (led == LED_GREEN)
{
if (current_led_state & LED_GREEN_ON_MASK)
{
current_led_state |= LED_GREEN_MASK;
ret = reset_timer(led_timer_h[2],V_TIMER_MODE_PERIODIC,delay*10,led_green_blink_timer_hook);
assert(ret == 0);
}
else
{
current_led_state |= (LED_GREEN_MASK | LED_GREEN_ON_MASK);
led_timer_h[2] = start_timer(V_TIMER_MODE_PERIODIC,delay*10,led_green_blink_timer_hook);
assert(led_timer_h[2] != 0);
}
}
else
{
if (current_led_state & LED_BLUE_ON_MASK)
{
current_led_state |= LED_BLUE_MASK;
ret = reset_timer(led_timer_h[3],V_TIMER_MODE_PERIODIC,delay*10,LED_BLUE_blink_timer_hook);
assert(ret == 0);
}
else
{
current_led_state |= (LED_BLUE_MASK | LED_BLUE_ON_MASK);
led_timer_h[3] = start_timer(V_TIMER_MODE_PERIODIC,delay*10,LED_BLUE_blink_timer_hook);
assert(led_timer_h[3] != 0);
}
}
}
示例8: create_game
/* External functions
*/
Game* create_game(void)
{
int ii;
Game* G = (Game*)calloc(1, sizeof(Game));
G->timer = create_timer();
G->graphics = create_graphics();
G->ui = create_ui(G->graphics);
/* Set up camera */
G->camera = transform_zero;
G->camera.orientation = quat_from_euler(0, -0.75f * kPi, 0);
G->camera.position.x = 4.0f;
G->camera.position.y = 2;
G->camera.position.z = 7.5f;
/* Load scene */
reset_timer(G->timer);
G->scene = create_scene("lightHouse.obj");
G->sun_light.position = vec3_create(-4.0f, 5.0f, 2.0f);
G->sun_light.color = vec3_create(1, 1, 1);
G->sun_light.size = 35.0f;
G->lights[0].color = vec3_create(1, 0, 0);
G->lights[1].color = vec3_create(1, 1, 0);
G->lights[2].color = vec3_create(0, 1, 0);
G->lights[3].color = vec3_create(1, 0, 1);
G->lights[4].color = vec3_create(0, 0, 1);
G->lights[5].color = vec3_create(0, 1, 1);
for(ii=0;ii<NUM_LIGHTS;++ii) {
float x = (20.0f/NUM_LIGHTS) * ii - 8.0f;
G->lights[ii].color = vec3_create(_rand_float(), _rand_float(), _rand_float());
G->lights[ii].color = vec3_normalize(G->lights[ii].color);
if(ii % 2)
G->lights[ii].position = vec3_create(x, _rand_float()*3 + 2.0f, 0.0f);
else
G->lights[ii].position = vec3_create(0.0f, _rand_float()*3 + 2.0f, x);
G->lights[ii].size = 5;
}
get_model(G->scene, 3)->material->specular_color = vec3_create(0.5f, 0.5f, 0.5f);
get_model(G->scene, 3)->material->specular_coefficient = 1.0f;
G->dynamic_lights = 1;
reset_timer(G->timer);
return G;
}
示例9: m_write_t
void m58846_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (id != 0)
return;
// timer 1: 7-bit fixed counter (manual specifically says 127)
if (++m_tmr_count[0] == 127)
{
m_tmr_count[0] = 0;
m_irqflag[1] = true;
m_possible_irq = true;
}
// timer 2: 8-bit user defined counter with auto-reload
if (m_v & 8 && ++m_tmr_count[1] == 0)
{
m_tmr_count[1] = m_tmr_reload;
m_irqflag[2] = true;
m_possible_irq = true;
m_port_t ^= 1;
m_write_t(m_port_t);
}
// schedule next timeout
reset_timer();
}
示例10: _auto_switch_start
status_t _auto_switch_start(void)
{
uint32_t duration = 0;
int32_t pic_switch_duration = 0;
/*if(pic_switch_timer)
{
printf("[PIC] play_pic_auto_switch_start pic_switch_timer is already created\n");
return GXCORE_ERROR;
}*/
pic_switch_duration = pmpset_get_int(PMPSET_PIC_SWITCH_DURATION);
// TODO: 时间暂时推迟下,解码时间太长
if(PMPSET_PIC_SWITCH_DURATION_3s == pic_switch_duration)duration = 3000;
else if(PMPSET_PIC_SWITCH_DURATION_5s == pic_switch_duration)duration = 5000;
else if(PMPSET_PIC_SWITCH_DURATION_7s == pic_switch_duration)duration = 7000;
else if(PMPSET_PIC_SWITCH_DURATION_10s== pic_switch_duration)duration = 10000;
if(0 != reset_timer(pic_switch_timer))
{
pic_switch_timer = create_timer(_auto_switch_pic, (int)duration, NULL, TIMER_REPEAT);
}
return GXCORE_SUCCESS;
}
示例11: app_pic_update_timer_reset
void app_pic_update_timer_reset(void)
{
if (reset_timer(sp_PicUpdateTimer) != 0)
{
sp_PicUpdateTimer = create_timer(picasa_pic_update_timeout, 500, NULL, TIMER_REPEAT);
}
}
示例12: server_recv_cb
/*
*
* xsocks UDP Response
* +------+----------+----------+----------+
* | ATYP | DST.ADDR | DST.PORT | DATA |
* +------+----------+----------+----------+
* | 1 | Variable | 2 | Variable |
* +------+----------+----------+----------+
*
*/
static void
server_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags) {
if (nread > 0) {
struct client_context *client = handle->data;
reset_timer(client);
int mlen = nread - PRIMITIVE_BYTES;
uint8_t *m = (uint8_t *)buf->base;
int rc = crypto_decrypt(m, (uint8_t *)buf->base, nread);
if (rc) {
logger_log(LOG_ERR, "invalid packet");
goto err;
}
memmove(m, m + addrlen, mlen - addrlen);
mlen -= addrlen;
forward_to_client(client, m , mlen);
} else {
goto err;
}
return;
err:
free(buf->base);
}
示例13: main
int main() {
test_setup();
perf_start();
for (int i = 0; i < NUM_ITER; ++i) {
test_clear();
reset_timer();
start_timer();
test_run(i);
stop_timer();
samples[i] = get_time();
}
perf_stop();
int check = test_check();
printf("Correct: %d\n", check);
for (int i = 0; i < NUM_ITER; ++i)
printf("TS[%d]: %d\n", i, samples[i]);
perf_print_all();
return 0;
}
示例14: machine
void mb3773_device::device_start()
{
m_watchdog_timer = machine().scheduler().timer_alloc( FUNC(watchdog_timeout), this );
reset_timer();
save_item( NAME(m_ck) );
}
示例15: run_n
void run_n(size_t n) {
d_num_iterations = n;
reset_timer();
start_timer();
d_benchmark.get_func()(this);
stop_timer();
}