示例#1
0
文件: timer.c 项目: rdgout/ircbot
void checktimers(time_t time) {
    timer *timer, *next;
    void *arg;
    tmrhandler_t func;

    for (timer = timers; timer; timer = next) {
        next = timer->next;

        if (timer->exectime > 0 && timer->exectime <= time) {
            arg = timer->arg;
            func = timer->handler;

            func(arg);

            switch (timer->type) {
                case TIMER_ONCE:
                    remove_timer(timer);
                    break;
                case TIMER_RECURRING:
                    /* Extend the time */
                    timer->exectime += timer->interval;
                    break;
            }
        }

        if (!timer->exectime)
            remove_timer(timer);
    }

}
示例#2
0
static int system_shell_timeout(void *userdata)
{
    struct shell_call_param* p_call_param = NULL;

    p_call_param = (struct shell_call_param*)userdata;

	if((p_call_param != s_plast_call_param) || (s_plast_call_param == NULL))
	{
		printf("time param error p_call=%p,plast_call=%p\n",p_call_param,s_plast_call_param);
		return 0;
	}

    p_call_param->time_out--;
    if(p_call_param->time_out > 0)
    {
	//WNOHANG pid子进程即使未结束也返回0
	if(waitpid(p_call_param->pid, &g_system_shell_ret_status, WNOHANG) == 0)
	{
	    if(p_call_param->step_proc)
		p_call_param->step_proc(p_call_param->userdata);
	}
	else
	{
	    s_plast_call_param = NULL;
		remove_timer(p_call_param->p_Timer);
	    if(p_call_param->finsh_proc)
		p_call_param->finsh_proc(p_call_param->userdata);
	    
	    
	    GxCore_Free(p_call_param);
	}
    }
    else
    {
		s_plast_call_param = NULL;
		kill(p_call_param->pid, SIGKILL);
		remove_timer(p_call_param->p_Timer);

	if(p_call_param->finsh_proc)
		p_call_param->finsh_proc(p_call_param->userdata);
	    
		
		GxCore_Free(p_call_param);
    }
    

    return 0;
}
示例#3
0
文件: TIMER.cpp 项目: mcgrue/maped2w
void ShutdownTimer() {
	if (!installed) return;

	remove_int(_maped_timer_handler);
	remove_timer();
	installed=false;
}
示例#4
0
文件: clock.c 项目: Cloudxtreme/epic5
int	update_system_timer (const char *entry)
{
	int	i;
	int	all = 0;

	if (entry == NULL)
		all = 1;

	for (i = 0; system_timers[i].name; i++)
	{
	    if (all == 1 || !strcmp(system_timers[i].name, entry))
	    {
		/* This needs to be set before calling 'system_timer' */
		get_time(&now);

		if (get_int_var(*system_timers[i].toggle_variable) &&
		    get_int_var(*system_timers[i].interval_variable))
			system_timer(&system_timers[i]);
		else
		{
		    if (timer_exists(system_timers[i].name))
			remove_timer(system_timers[i].name);
		}

		if (all == 0)
			return 0;
	    }
	}

	if (all == 1)
		return 0;

	return -1;
}
示例#5
0
文件: mutex.c 项目: jschiefer/bibo
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
			   unsigned long abstime) {
    waitqueue_t entry;
    timer_t timer = { 0,  (void (*)(void*)) make_running, ctid };
    tid_t owner;
    int result = 0;
    // check if mutex is available, if not, go to sleep
    grab_kernel_lock();

    entry.thread = ctid;
    add_to_waitqueue(&cond->waiters, &entry);
    pthread_mutex_unlock(mutex);
    if (abstime)
	add_timer(abstime - get_system_up_time(), &timer);

    wait();
    if (abstime) {
	if (get_timer_count(timer))
	    remove_timer(&timer);
	else
	    result = ETIMEDOUT;
    }
    remove_from_waitqueue(&entry);
    pthread_mutex_lock(mutex);
    return 0;
}
示例#6
0
  ~Alleg4System() {
    clock_exit();
    remove_timer();
    allegro_exit();

    g_instance = nullptr;
  }
示例#7
0
/* Internal version of start_timer that does not protect itself, assuming this has already been done.
 * Otherwise does as explained above in start_timer.
 */
STATICFNDEF void start_timer_int(TID tid, int4 time_to_expir, void (*handler)(), int4 hdata_len, void *hdata)
{
	ABS_TIME at;

 	assert(0 != time_to_expir);
	sys_get_curr_time(&at);
	if (first_timeset)
	{
		init_timers();
		first_timeset = FALSE;
	}
	/* We expect no timer with id=<tid> to exist in the timer queue currently. This is asserted in "add_timer" call below.
	 * In pro though, we'll be safe and remove any tids that exist before adding a new entry with the same tid - 2009/10.
	 * If a few years pass without the assert failing, it might be safe then to remove the PRO_ONLY code below.
	 */
#	ifndef DEBUG
	if (timeroot && (timeroot->tid == tid))
		sys_canc_timer();
	remove_timer(tid); /* Remove timer from chain */
#	endif
	/* Check if # of free timer slots is less than minimum threshold. If so, allocate more of those while it is safe to do so */
	if ((GT_TIMER_EXPAND_TRIGGER > num_timers_free) && (1 > timer_stack_count))
		gt_timers_alloc();
	add_timer(&at, tid, time_to_expir, handler, hdata_len, hdata);	/* Link new timer into timer chain */
	if ((timeroot->tid == tid) || !timer_active)
		start_first_timer(&at);
}
示例#8
0
文件: time.c 项目: 1153/otp
void
erts_cancel_timer(ErlTimer* p)
{
    erts_smp_mtx_lock(&tiw_lock);
    if (!p->active) { /* allow repeated cancel (drivers) */
	erts_smp_mtx_unlock(&tiw_lock);
	return;
    }

    /* is it the 'min' timer, remove min */
    if (p == tiw_min_ptr) {
	tiw_min_ptr = NULL;
	tiw_min     = 0;
    }

    remove_timer(p);
    p->slot = p->count = 0;

    if (p->cancel != NULL) {
	erts_smp_mtx_unlock(&tiw_lock);
	(*p->cancel)(p->arg);
	return;
    }
    erts_smp_mtx_unlock(&tiw_lock);
}
void app_tr_cas_osd_roll_timer_check(void)
{
	if (FALSE == s_bOsdRollEnable)
	{
		return;	
	}
	
	GxCore_SemWait(s_semNotifyRoll);
	
	if (s_rollingInfo.period > 0)
	{
		printf("[app_tr_cas_osd_roll_timer_check]Create Roll(%ds) Timer>>>+++.\n",\
			  		s_rollingInfo.period);

		if (s_rollingInfo.timer_handle)
		{
			remove_timer(s_rollingInfo.timer_handle);
			s_rollingInfo.timer_handle = NULL;
		}
		
		s_rollingInfo.timer_handle = create_timer(tr_cas_timer_roll,\
			   									  s_rollingInfo.period*1000,\
			   			   						  NULL, TIMER_ONCE);
	}
	
	GxCore_SemPost(s_semNotifyRoll);
	return;
}
示例#10
0
文件: timer.c 项目: CurieBSP/main
/**
 * Execute the callback of a timer.
 *
 * @param expiredTimer pointer on the timer
 *
 * WARNING: expiredTimer MUST NOT be null (rem: static function )
 */
static void execute_callback(T_TIMER_LIST_ELT *expiredTimer)
{
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
	_log(
		"\nINFO : execute_callback : executing callback of timer 0x%x  (now = %u - expiration = %u)",
		(uint32_t)expiredTimer,
		get_uptime_ms(), expiredTimer->desc.expiration);
#endif
	int flags = irq_lock();

	/* if the timer was not stopped by its own callback */
	if (E_TIMER_RUNNING == expiredTimer->desc.status) {
		remove_timer(expiredTimer);
		/* add it again if repeat flag was on */
		if (expiredTimer->desc.repeat) {
			expiredTimer->desc.expiration = get_uptime_ms() +
							expiredTimer->desc.
							delay;
			add_timer(expiredTimer);
		}
	}
	irq_unlock(flags);

	/* call callback back */
	if (NULL != expiredTimer->desc.callback) {
		expiredTimer->desc.callback(expiredTimer->desc.data);
	} else {
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
		_log("\nERROR : execute_callback : timer callback is null ");
#endif
		panic(E_OS_ERR);
	}
}
示例#11
0
文件: timer.c 项目: CurieBSP/main
/**
 *  Remove the timer in Chained list of timers.
 *     This service may panic if:
 *         tmr parameter is is null, invalid, or timer is not running.
 *
 * Authorized execution levels:  task, fiber, ISR
 *
 * @param tmr : handler on the timer (value returned by timer_create ).
 *
 */
void timer_stop(T_TIMER tmr)
{
	T_TIMER_LIST_ELT *timer = (T_TIMER_LIST_ELT *)tmr;
	bool doSignal = false;

	if (NULL != timer) {
		int flags = irq_lock();
		/* if timer is active */
		if (timer->desc.status == E_TIMER_RUNNING) {
#ifdef __DEBUG_OS_ABSTRACTION_TIMER
			_log(
				"\nINFO : timer_stop : stopping timer at addr = 0x%x",
				(uint32_t)timer);
#endif
			/* remove the timer */

			if (g_CurrentTimerHead == timer) {
				doSignal = true;
			}

			remove_timer(timer);

			irq_unlock(flags);

			if (doSignal) {
				/* the next timer to expire was removed, unblock timer_task to assess the change */
				signal_timer_task();
			}
		} else { /* tmr is not running */
			irq_unlock(flags);
		}
	} else { /* tmr is not a timer from g_TimerPool_elements */
		panic(E_OS_ERR);
	}
}
示例#12
0
ttitle_screen::~ttitle_screen()
{
	if(logo_timer_id_) {
		remove_timer(logo_timer_id_);
	}
	delete debug_clock_;
}
void app_jiuzhou_ads_stop(uint8_t type)
{
		GxAvRect rect;	

		if(type >= AD_JIUZHOU_TYPE_MAX)
		{
			printf("%s type=%d\n",__FUNCTION__,type);	
			return ;
		}
	
		printf("%s file_ddram_path=%s\n",__FUNCTION__,ads_jiuzhou_para[type].file_ddram_path);	
	
		if (NULL != ads_jiuzhou_para[type].ad_timer)
		{
			remove_timer(ads_jiuzhou_para[type].ad_timer);
			ads_jiuzhou_para[type].ad_timer = NULL;
		}

		if (NULL != ads_jiuzhou_para[type].file_ddram_path)
		{
			rect.x = 0;
			rect.y = 0;
			rect.width = VIDEO_WINDOW_W;
			rect.height = VIDEO_WINDOW_H;
			advertisement_clear_frame(rect);			
//			advertisement_clear_frame(ads_jiuzhou_para[type].rectdest);
			memset(&ads_jiuzhou_para[type],0,sizeof(ad_play_para));
//			advertisement_hide();
		}
		
		return ;
}
示例#14
0
SIGNAL_HANDLER int text_view_destroy(const char* widgetname, void *usrdata)
{		
	/*list get*/
	play_list* list = NULL;
	char* path = NULL;
	list = play_list_get(PLAY_LIST_TYPE_TEXT);
	APP_CHECK_P(list, GXCORE_ERROR);
	if(list->play_no >= list->nents) return GXCORE_ERROR;
	path = explorer_static_path_strcat(list->path, list->ents[list->play_no]);
	APP_CHECK_P(path, GXCORE_ERROR);
	
	/*save tag*/
	if(0 < stop_line)
	{
		pmp_save_tag(path, stop_line);
	}

	/*auto roll*/
	if(text_auto_roll_timer)
	{
		remove_timer(text_auto_roll_timer);
		text_auto_roll_timer = NULL;
	}

	app_set_win_destroy_flag(MEDIA_TEXT_WIN);

      return 0;
}
示例#15
0
void tlobby_main::post_show(twindow& /*window*/)
{
	window_ = nullptr;
	remove_timer(lobby_update_timer_);
	lobby_update_timer_ = 0;
	plugins_context_.reset();
}
示例#16
0
文件: c_link.cpp 项目: Zhanyin/taomee
bool c_link::end_timer(bool force )
{
	if( m_timer_counter > 0 )
	{
		m_timer_counter--;
	}
	else
	{
		m_timer_counter = 0;
	}

	if( ( 0 == m_timer_counter || force ) && m_timer_id != 0 )
	{
		remove_timer( &m_timer, m_timer_id );
		m_timer_counter = 0;
		m_timer_id = 0;
	}

	if( 0 == m_timer_id )
	{
		return true;
	}
	else
	{
		return false;
	}
}
示例#17
0
bool AngelFight::EndTimer( bool force /*= false*/ )
{
    //DEBUG_LOG( "AngelFight::EndTimer If Force[%d]", int32_t(force) );
    if( m_nTimerCounter > 0 )
    {
        m_nTimerCounter--;
    }
    else
    {
        m_nTimerCounter = 0;
    }

    if( ( 0 == m_nTimerCounter || force ) && m_nTimerID != 0 )
    {
        remove_timer( &m_timer, m_nTimerID );
        //DEBUG_LOG( "Remove Timer OK TimerID:[%d]", m_nTimerID);
        m_nTimerCounter = 0;
        m_nTimerID = 0;
    }

    if( 0 == m_nTimerID )
    {
        return true;
    }
    else
    {
        return false;
    }
}
示例#18
0
	~texecutor()
	{
		const unsigned long id = executing_id;
		executing_id = 0;
		if(executing_id_removed) {
			remove_timer(id);
		}
	}
示例#19
0
	~texecutor()
	{
		const size_t id = executing_id;
		executing_id = 0;
		if(executing_id_removed) {
			remove_timer(id);
		}
	}
SIGNAL_HANDLER  int app_factory_menu_dplay_destroy(const char* widgetname, void *usrdata)
{
	

	remove_timer(spApp_fatory_time_dplay);
	spApp_fatory_time_dplay = NULL;


	return 0;
示例#21
0
void Resolver::run_callback(int err, const Hosts* hosts)
{
    remove_timer();
    if(cb_)
    {
        cb_(err, hosts);
        cb_ = nullptr;
    }
}
示例#22
0
static status_t pic_box_timer_stop(void)
{
	if(pic_box_hide_timer)
	{
		remove_timer(pic_box_hide_timer);
		pic_box_hide_timer = NULL;
	}
	return GXCORE_SUCCESS;
}
示例#23
0
void TimerSDL::stop_all() {
	
	for (int i=0;i<MAX_TIMERS;i++) {
		if (timers[i].active)
			remove_timer( i );
		
	}
	
}
示例#24
0
void app_picasa_feeds_update_timer_stop(void)
{
	if(sp_PicasaFeedsUpdateTimer != NULL)
	{
		//timer_stop(sp_PicasaFeedsUpdateTimer);
		remove_timer(sp_PicasaFeedsUpdateTimer);
		sp_PicasaFeedsUpdateTimer = NULL;
	}
}
示例#25
0
文件: adc.c 项目: Elios007/alceosd
void adc_stop(void)
{
    remove_timer(adc_sampler_timer);
    adc_sampler_timer = NULL;
    buf[0] = NULL;
    buf[1] = NULL;
    ANSELAbits.ANSA0 = 0;
    ANSELAbits.ANSA1 = 0;
}
void gif_stop(void)
{
	if(sp_YoutubePlayGifTimer)
	{
		remove_timer(sp_YoutubePlayGifTimer);
		sp_YoutubePlayGifTimer = NULL;
	}

	app_youtube_play_hide_gif();
}
示例#27
0
文件: timers.c 项目: Absolight/Prima
Bool
apc_timer_destroy( Handle self)
{
   objCheck false;
   if ( is_opt( optActive) && var handle && IsWindow(( HWND)(( PWidget) var owner)-> handle)) {
      if ( !KillTimer(( HWND)(( PWidget) var owner)-> handle, var handle)) apiErr;
   }
   remove_timer( self, var owner);
   return true;
}
示例#28
0
 // Dequeue all timers not later than the current time.
 virtual void get_ready_timers(op_queue<operation>& ops)
 {
   const time_type now = Time_Traits::now();
   while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_))
   {
     per_timer_data* timer = heap_[0].timer_;
     ops.push(timer->op_queue_);
     remove_timer(*timer);
   }
 }
示例#29
0
status_t _auto_switch_stop(void)
{
    if(pic_switch_timer)
    {
        remove_timer(pic_switch_timer);
        pic_switch_timer = NULL;
    }

    return GXCORE_SUCCESS;
}
示例#30
0
static void
pt_window_ready_to_play (PtWindow *win,
                         gboolean  state)
{
    /* Set up widget sensitivity/visibility, actions, labels, window title
       and timer according to the state of PtPlayer (ready to play or not).
       Reset tooltips for insensitive widgets. */

    gchar     *display_name = NULL;

    enable_win_actions (win, state);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->priv->button_play), FALSE);
    gtk_widget_set_visible (win->priv->button_play, state);
    gtk_widget_set_visible (win->priv->button_open, !state);

    gtk_widget_set_sensitive (win->priv->button_play, state);
    gtk_widget_set_sensitive (win->priv->button_fast_back, state);
    gtk_widget_set_sensitive (win->priv->button_fast_forward, state);
    gtk_widget_set_sensitive (win->priv->button_jump_back, state);
    gtk_widget_set_sensitive (win->priv->button_jump_forward, state);
    gtk_widget_set_sensitive (win->priv->speed_scale, state);

    if (state) {
        destroy_progress_dlg (win);
        display_name = pt_player_get_filename (win->priv->player);
        if (display_name) {
            gtk_window_set_title (GTK_WINDOW (win), display_name);
            g_free (display_name);
        }
        gtk_recent_manager_add_item (
            win->priv->recent,
            pt_player_get_uri (win->priv->player));

        change_play_button_tooltip (win);
        change_jump_back_tooltip (win);
        change_jump_forward_tooltip (win);
        pt_waveslider_set_follow_cursor (PT_WAVESLIDER (win->priv->waveslider), TRUE);
        win->priv->wavedata = pt_player_get_data (win->priv->player);
        pt_waveslider_set_wave (PT_WAVESLIDER (win->priv->waveslider),
                                win->priv->wavedata);
        /* add timer after waveslider, didn't update cursor otherwise sometimes */
        add_timer (win);

    } else {
        gtk_label_set_text (GTK_LABEL (win->priv->pos_label), "00:00.0");
        gtk_window_set_title (GTK_WINDOW (win), "Parlatype");
        gtk_widget_set_tooltip_text (win->priv->button_jump_back, NULL);
        gtk_widget_set_tooltip_text (win->priv->button_jump_forward, NULL);
        remove_timer (win);
        pt_wavedata_free (win->priv->wavedata);
        win->priv->wavedata = NULL;
        pt_waveslider_set_wave (PT_WAVESLIDER (win->priv->waveslider),
                                win->priv->wavedata);
    }
}