示例#1
0
void TfmccSrcStop (Agent * agent)
{
  TfmccSrcInfo * tsi = (TfmccSrcInfo *) agent->info_;
  
  tsi->active_ = 0;
  
  CancelTimer (agent, & (tsi->sendPktTimerEvnt_));
  tsi->sendPktTimerEvnt_ = NULL;
  CancelTimer (agent, & (tsi->noFdbkTimerEvnt_));
  tsi->noFdbkTimerEvnt_ = NULL;
}
示例#2
0
// ---------------------------------------------------------------------------
// CLingerConnection::HandleSettingsChanged
// ---------------------------------------------------------------------------
//
void CLingerConnection::HandleSettingsChanged()
    {
    LOG_1( _L("CLingerConnection::HandleSettingsChangedL") );
    
    TInt oldLingerInterval( iLingerInterval );
    
    ReadSettings();
   
    if ( iLingerInterval != oldLingerInterval )
        {
        if ( iLingerInterval == 0 )
            {
            // Linger was turned off
            StopLinger();
            return; 
            }
        
        if ( iLingering )
            {          
            if ( iLingerInterval > 0 )
                {
                // Linger timer has a new positive value
                CancelTimer();
                StartTimer( iLingerInterval );
                }
            else
                {
                // Linger timer has a new negative value
                // -> linger forever
                CancelTimer();
                iLingering = EFalse; 
                }        
            }
        else if ( iAttached )
            {
            if ( ( oldLingerInterval > 0 ) && ( iLingerInterval < 0 ) )
                {
                // Linger timer has a new negative value
                // -> linger forever
                CancelTimer();     
                }
            else if ( ( oldLingerInterval < 0 ) && ( iLingerInterval > 0 ) )
                {
                // Linger timer has a new positive value
                CancelTimer();
                StartTimer( KDataInactivityInterval );
                }      
            }    
        else // not attached, not lingering
            {
            StartLinger();
            }        
        }
    }
示例#3
0
/** 
 *  @brief This function frees the structure of adapter
 *    
 *  @param priv    A pointer to wlan_private structure
 *  @return 	   n/a
 */
void
wlan_free_adapter(wlan_private * priv)
{
    wlan_adapter *Adapter = priv->adapter;

    ENTER();

    if (!Adapter) {
        PRINTM(INFO, "Why double free adapter?:)\n");
        return;
    }

    PRINTM(INFO, "Free Command buffer\n");
    FreeCmdBuffer(priv);

    PRINTM(INFO, "Free CommandTimer\n");
    if (Adapter->CommandTimerIsSet) {
        CancelTimer(&Adapter->MrvDrvCommandTimer);
        Adapter->CommandTimerIsSet = FALSE;
    }
    FreeTimer(&Adapter->MrvDrvCommandTimer);
#ifdef REASSOCIATION
    PRINTM(INFO, "Free MrvDrvTimer\n");
    if (Adapter->TimerIsSet) {
        CancelTimer(&Adapter->MrvDrvTimer);
        Adapter->TimerIsSet = FALSE;
    }
    FreeTimer(&Adapter->MrvDrvTimer);
#endif /* REASSOCIATION */

    if (Adapter->bgScanConfig) {
        kfree(Adapter->bgScanConfig);
        Adapter->bgScanConfig = NULL;
    }

    OS_FREE_LOCK(&Adapter->CurrentTxLock);
    OS_FREE_LOCK(&Adapter->QueueSpinLock);

    PRINTM(INFO, "Free ScanTable\n");
    if (Adapter->ScanTable) {
        kfree(Adapter->ScanTable);
        Adapter->ScanTable = NULL;
    }

    PRINTM(INFO, "Free Adapter\n");

    /* Free the adapter object itself */
    kfree(Adapter);
    priv->adapter = NULL;
    LEAVE();
}
示例#4
0
void
SystemTimeUserTimer::Schedule(bigtime_t nextTime, bigtime_t interval,
	uint32 flags, bigtime_t& _oldRemainingTime, bigtime_t& _oldInterval)
{
	InterruptsWriteSequentialLocker locker(sUserTimerLock);

	// get the current time
	bigtime_t now = system_time();

	// Cancel the old timer, if still scheduled, and get the previous values.
	if (fScheduled) {
		CancelTimer();

		_oldRemainingTime = fNextTime - now;
		_oldInterval = fInterval;

		fScheduled = false;
	} else {
		_oldRemainingTime = B_INFINITE_TIMEOUT;
		_oldInterval = 0;
	}

	// schedule the new timer
	fNextTime = nextTime;
	fInterval = interval;
	fOverrunCount = 0;

	if (nextTime == B_INFINITE_TIMEOUT)
		return;

	if ((flags & B_RELATIVE_TIMEOUT) != 0)
		fNextTime += now;

	ScheduleKernelTimer(now, fInterval > 0);
}
示例#5
0
NS_IMETHODIMP
IdleTaskRunner::Run()
{
  if (!mCallback) {
    return NS_OK;
  }

  // Deadline is null when called from timer.
  TimeStamp now = TimeStamp::Now();
  bool deadLineWasNull = mDeadline.IsNull();
  bool didRun = false;
  bool allowIdleDispatch = false;
  if (deadLineWasNull || ((now + mBudget) < mDeadline)) {
    CancelTimer();
    didRun = mCallback(mDeadline);
    // If we didn't do meaningful work, don't schedule using immediate
    // idle dispatch, since that could lead to a loop until the idle
    // period ends.
    allowIdleDispatch = didRun;
  } else if (now >= mDeadline) {
    allowIdleDispatch = true;
  }

  if (mCallback && (mRepeating || !didRun)) {
    Schedule(allowIdleDispatch);
  } else {
    mCallback = nullptr;
  }

  return NS_OK;
}
示例#6
0
/* Cancel a network timer object. */
void _hx_sys_untimeout(sys_timeout_handler handler, void* arg)
{
	__network_timer_object* pTimerObject = timer_list.pNext;
	BOOL bResult = FALSE;

	while (pTimerObject != &timer_list)
	{
		if ((pTimerObject->handler == handler) && (pTimerObject->handler_param == arg))
		{
			break;
		}
		pTimerObject = pTimerObject->pNext;
	}
	if (pTimerObject == &timer_list)
	{
		//_hx_printf("%s:can not find the timer to delete.\r\n", __func__);
		return;
	}
	/* Cancel the HelloX timer first. */
	bResult = CancelTimer(pTimerObject->hTimer);
	if (!bResult) /* The timer maybe triggered and cancelled before. */
	{
		return;
	}
	
	/* Release the network timer object. */
	_hx_release_network_tmo(pTimerObject);
}
示例#7
0
    void stop()
    {
        ASSERT( active );

        CancelTimer(client_slot);
        active=false;
    }
示例#8
0
// ---------------------------------------------------------------------------
// CLingerConnection::StartTimer()
// ---------------------------------------------------------------------------
//
void CLingerConnection::StartTimer( TInt aTimerInterval, TBool aReset )
    {
    LOG_1( _L("CLingerConnection::StartTimer") );
    
    if ( aReset )
        {
        iLingerTimerCount = 0;
        }
    
    TCallBack cb( TimerCallBack, this );

    // if linger timer is negative we should not start timer but linger forever...
    if ( iLingerInterval > 0 )
        {
        LOG_2( _L("iTimer->Start: aTimerInterval: %d"), aTimerInterval );
        
        if( aTimerInterval > KMaxTimerInSeconds )
            {
            // Maximum allowed interval is 30 minutes.
            // This restriction comes from TTimeIntervalMicroSeconds32
            iCurrentTimerInterval = KMaxTimerInSeconds;
            }
        else
            {
            // use current value
            iCurrentTimerInterval = aTimerInterval;
            }    
    
        LOG_2( _L("iTimer->Start: iCurrentTimerInterval: %d"), iCurrentTimerInterval );
        CancelTimer();
        iTimer->Start( ( iCurrentTimerInterval * KSecondsToMicro ), 
                       ( iCurrentTimerInterval * KSecondsToMicro ), 
                       cb );    
        }
    }
示例#9
0
nsresult
IdleTaskRunner::Cancel()
{
  CancelTimer();
  mTimer = nullptr;
  mScheduleTimer = nullptr;
  mCallback = nullptr;
  return NS_OK;
}
示例#10
0
    void process(Packet_ACK ack)
    {
        ASSERT( ack.server_slot==server_slot && active && ack.tid==tid );

        if( !ready ) CancelProcessing(server_slot);

        if( timeout ) CancelTimer(server_slot);

        active=false;
    }
示例#11
0
void
RealTimeUserTimer::Schedule(bigtime_t nextTime, bigtime_t interval,
	uint32 flags, bigtime_t& _oldRemainingTime, bigtime_t& _oldInterval)
{
	InterruptsWriteSequentialLocker locker(sUserTimerLock);

	// get the current time
	bigtime_t now = system_time();

	// Cancel the old timer, if still scheduled, and get the previous values.
	if (fScheduled) {
		CancelTimer();

		_oldRemainingTime = fNextTime - now;
		_oldInterval = fInterval;

		if (fAbsolute) {
			SpinLocker globalListLocker(sAbsoluteRealTimeTimersLock);
			sAbsoluteRealTimeTimers.Remove(this);
		}

		fScheduled = false;
	} else {
		_oldRemainingTime = B_INFINITE_TIMEOUT;
		_oldInterval = 0;
	}

	// schedule the new timer
	fNextTime = nextTime;
	fInterval = interval;
	fOverrunCount = 0;

	if (nextTime == B_INFINITE_TIMEOUT)
		return;

	fAbsolute = (flags & B_RELATIVE_TIMEOUT) == 0;

	if (fAbsolute) {
		fRealTimeOffset = rtc_boot_time();
		fNextTime -= fRealTimeOffset;

		// If periodic, check whether the start time is too far in the past.
		if (fInterval > 0)
			CheckPeriodicOverrun(now);

		// add the absolute timer to the global list
		SpinLocker globalListLocker(sAbsoluteRealTimeTimersLock);
		sAbsoluteRealTimeTimers.Insert(this);
	} else
		fNextTime += now;

	ScheduleKernelTimer(now, false);
}
示例#12
0
// ---------------------------------------------------------------------------
// ~CLingerConnection
// ---------------------------------------------------------------------------
//
CLingerConnection::~CLingerConnection()
    {
    LOG_1( _L("CLingerConnection::~CLingerConnection") );
    
    // Cancel timer
    CancelTimer();
    
    // Delete timer
    delete iTimer;
    
    // Close RConnection object
    CloseConnection();
    }
示例#13
0
// ---------------------------------------------------------------------------
// CLingerConnection::StopLinger
// ---------------------------------------------------------------------------
//
void CLingerConnection::StopLinger()
    {
    LOG_1( _L("CLingerConnection::StopLinger") );
    
    if ( iAttached )
        {    
        CancelTimer();
        CloseConnection();           
        iLingering = EFalse;
        
        LOG_1( _L("Linger timer stopped") );
        }      
    }
示例#14
0
/*!	Stops the timer, if it is active.

	Called when the thread whose CPU time is referred to by the timer is
	unscheduled, or, when the timer is canceled.

	The caller must hold \c sUserTimerLock.
*/
void
ThreadTimeUserTimer::Stop()
{
	if (fThread == NULL)
		return;

	ASSERT(fScheduled);

	// cancel the kernel timer
	CancelTimer();
	fScheduled = false;

	// TODO: To avoid odd race conditions, we should check the current time of
	// the thread (ignoring the time since last_time) and manually fire the
	// user event, if necessary.
}
示例#15
0
void CBaseScreen::OnShow(BOOL bShow) // 窗口需要显示或者隐藏的时候收到的消息
{
	if (bShow)
	{
		m_pGlobal->m_pKey->forceClear();
		m_bVisible = TRUE;
	}
	else
	{
		m_parent = NULL;
		m_bNeedRedraw = FALSE;
		m_bVisible = FALSE;
		
		CancelTimer();
	}
}
示例#16
0
/*!	Deactivates the timer, if it is activated.

	The caller must hold \c time_lock and \c sUserTimerLock.
*/
void
ThreadTimeUserTimer::Deactivate()
{
	if (fThread == NULL)
		return;

	// unschedule, if scheduled
	if (fScheduled) {
		CancelTimer();
		fScheduled = false;
	}

	// deactivate
	fThread->UserTimerDeactivated(this);
	fThread->ReleaseReference();
	fThread = NULL;
}
示例#17
0
/*!	Called when the real-time clock has been changed.

	The caller must hold \c sUserTimerLock. Optionally the caller may also
	hold \c sAbsoluteRealTimeTimersLock.
*/
void
RealTimeUserTimer::TimeWarped()
{
	ASSERT(fScheduled && fAbsolute);

	// get the new real-time offset
	bigtime_t oldRealTimeOffset = fRealTimeOffset;
	fRealTimeOffset = rtc_boot_time();
	if (fRealTimeOffset == oldRealTimeOffset)
		return;

	// cancel the kernel timer and reschedule it
	CancelTimer();

	fNextTime += oldRealTimeOffset - fRealTimeOffset;

	ScheduleKernelTimer(system_time(), fInterval > 0);
}
示例#18
0
/*!	Schedules/cancels the kernel timer as necessary.

	\c fRunningThreads must be up-to-date.
	The caller must hold \c time_lock and \c sUserTimerLock.

	\param unscheduling \c true, when the current thread is in the process of
		being unscheduled.
*/
void
TeamTimeUserTimer::_Update(bool unscheduling)
{
	// unschedule the kernel timer, if scheduled
	if (fScheduled)
		CancelTimer();

	// if no more threads are running, we're done
	if (fRunningThreads == 0) {
		fScheduled = false;
		return;
	}

	// There are still threads running. Reschedule the kernel timer.
	bigtime_t now = fTeam->CPUTime(unscheduling);

	// If periodic, check whether the start time is too far in the past.
	if (fInterval > 0)
		CheckPeriodicOverrun(now);

	if (fNextTime > now) {
		fTimer.schedule_time = system_time()
			+ (fNextTime - now + fRunningThreads - 1) / fRunningThreads;
		// check for overflow
		if (fTimer.schedule_time < 0)
			fTimer.schedule_time = B_INFINITE_TIMEOUT;
	} else
		fTimer.schedule_time = 0;
	fTimer.period = 0;
		// We reschedule periodic timers manually in HandleTimer() to avoid
		// rounding errors.

	add_timer(&fTimer, &HandleTimerHook, fTimer.schedule_time,
		B_ONE_SHOT_ABSOLUTE_TIMER | B_TIMER_USE_TIMER_STRUCT_TIMES);
		// We use B_TIMER_USE_TIMER_STRUCT_TIMES, so period remains 0, which
		// our base class expects.

	fScheduled = true;
}
示例#19
0
/**
 * At construction time, we want to listen to a tcp socket and emit a signal
 * when reading is finished.
 *
 * @param socket -- The socket to construct message from.
 * @param target -- The target canceller/receiver.
 *
 * @version
 * - JR Lewis      pre-2012.02.08
 *   - Initial version.
 * - JR Lewis      2012.02.08
 *   - Bringing this into the net project.
 * - JR Lewis      2012.02.13
 *   - Adding target.
 */
MessageAssembler::MessageAssembler(QTcpSocket& socket, QObject* target)
: QObject(0)
, socket(socket)
, block_size(0)
, cancel(false)
{
    bool r = QObject::connect( &socket
                             , SIGNAL(readyRead())
                             , this
                             , SLOT(OnReadyRead()));
    assert(r);

    r = QObject::connect( target
                        , SIGNAL(CancelTimer())
                        , this
                        , SLOT(OnCancel()));
    assert(r);

    r = QObject::connect( this
                        , SIGNAL(MessageConstructed(QString const&))
                        , target
                        , SLOT(OnMessageConstructed(QString const&)));
    assert(r);
}
示例#20
0
文件: condvar.c 项目: cod5/kielder
int CondTimedWait (volatile struct Cond *cond, struct Mutex *mutex, struct TimeVal *tv)
{
	struct Process *proc;
	struct Timer timer;
	
	if (current_process == NULL)
		return 0;
	
	DisableInterrupts();
	
	if (mutex->locked == TRUE)   
	{
		/* Release Mutex */

		proc = LIST_HEAD (&mutex->blocked_list);
		
		if (proc != NULL)
		{
			LIST_REM_HEAD (&mutex->blocked_list, blocked_entry);
			proc->state = PROC_STATE_READY;
			SchedReady (proc);
		}
		else
		{
			mutex->locked = FALSE;
		}
	}
	else
	{
		KPANIC ("CondTimedWait() on a free mutex");
	}
	
	
	/* Block current process on Condvar */

	LIST_ADD_TAIL (&cond->blocked_list, current_process, blocked_entry);
		
	SetTimer (&timer, TIMER_TYPE_RELATIVE, tv, &CondTimedWaitCallout, &cond);
	current_process->state = PROC_STATE_COND_BLOCKED;
	SchedUnready (current_process);
	Reschedule();

	CancelTimer (&timer);

	/* Now acquire mutex */
	
	if (mutex->locked == TRUE)
	{
		LIST_ADD_TAIL (&mutex->blocked_list, current_process, blocked_entry);
		current_process->state = PROC_STATE_MUTEX_BLOCKED;
		SchedUnready (current_process);
		Reschedule();
	}
	else
	{
		mutex->locked = TRUE;
	}
	
	
	EnableInterrupts();
	
	if (cond == NULL)
		return -1;
	else
		return 0;
}
示例#21
0
//Window procedure of Hello World.
static DWORD HelloWorldProc(HANDLE hWnd,UINT message,WORD wParam,DWORD lParam)
{
	static HANDLE hDC = NULL;
	static int cx = 0,cy = 0,r = 0;       //Circle's center and radius.
	__RECT rect;       //Window's rectangle.
	//HANDLE hPen,hOldPen;
	//HANDLE hBrush,hOldBrush;
	static HANDLE hTimer = NULL;     //Timer handle.
	static int hour = 3;
	static int minu = 25;
	static int secd = 0;

	switch(message)
	{
	case WM_CREATE:    //Will receive this message when the window is created.
		hTimer = SetTimer(
			(DWORD)hWnd,
			250,       //Current version's timer is not accurate since clock chip is not 
			           //reinitialized.
			NULL,
			NULL,
			TIMER_FLAGS_ALWAYS);
		if(NULL == hTimer)
		{
			break;
		}
		GetWindowRect(hWnd,&rect,GWR_INDICATOR_CLIENT);
		cx = (rect.right - rect.left) / 2;
		cy = (rect.bottom - rect.top) / 2;
		r = cx > cy ? cy : cx;
		r -= 10;
		hDC = GetClientDC(hWnd);
		break;
	case WM_TIMER:     //Only one timer can be set for one window in current version.
		EraseClockPointer(hDC,cx,cy,r,hour,minu,secd);
		secd ++;
		if(secd == 60)
		{
			minu ++;
			secd = 0;
		}
		if(minu == 60)
		{
			hour ++;
			minu = 0;
		}
		if(hour == 12)
		{
			hour = 0;
		}
		DrawClockPointer(hDC,cx,cy,r,hour,minu,secd);
		/*
		hDC = GetClientDC(hWnd);
		if(!GetWindowRect(hWnd,&rect,GWR_INDICATOR_CLIENT))
		{
			break;
		}
		//Calculate the circle's center coordinate and radius.
		cx = (rect.right - rect.left) / 2;
		cy = (rect.bottom - rect.top) / 2;
		r  = cx > cy ? cy : cx;
		r -= 10;  //Keep 10 pixel space between circle and window frame.

		//Create the pen and brush object used to draw circle.
		hPen = CreatePen(0,1,RGB(0xC0,0,0));
		if(NULL == hPen)
		{
			break;
		}
		hBrush = CreateBrush(FALSE,RGB(0xC0,0,0));
		if(NULL == hBrush)
		{
			break;
		}
		hOldPen = SelectPen(hDC,hPen);
		hOldBrush = SelectBrush(hDC,hBrush);
		DrawClockPointer(hDC,cx,cy,r,hour,minu,secd);
		//Restore original pen and brush for this window's DC.
		SelectPen(hDC,hOldPen);
		SelectBrush(hDC,hOldBrush);
		DestroyPen(hPen);
		DestroyBrush(hBrush);*/
		break;
	case WM_DRAW:
		DrawClockFace(hWnd);
		DrawClockPointer(hDC,cx,cy,r,hour,minu,secd);
		break;
	case WM_CLOSE:
		CloseWindow(hWnd);  //Exit application.
		if(NULL != hTimer)
		{
			CancelTimer(hTimer);
		}
		break;
	default:
		break;
	}
	return DefWindowProc(hWnd,message,wParam,lParam);
}
示例#22
0
// 窗口被销毁时收到的命令
int CBaseScreen::OnDestroy(void)
{
	if (m_bTimerOn) CancelTimer();
	return 0;
}
示例#23
0
void CBaseScreen::CancelAllForDoEnter()
{
	CancelTimer();
}
示例#24
0
BOOL CBaseScreen::OnSuspend()
{
	m_bVisible = FALSE;
	if (m_bTimerOn) CancelTimer();
	return TRUE;
}
示例#25
0
IdleTaskRunner::~IdleTaskRunner()
{
  CancelTimer();
}
示例#26
0
void CHoldGesture::HandleMouseUp (int x, int y)
{
	CancelTimer ();
}
示例#27
0
void CHoldGesture::HandleMouseMove (int x, int y)
{
	if (!IsInside (x, y))
		CancelTimer ();
}
示例#28
0
void RTD::T105TimerStop(void)
{
    /* Stop timer (T105) */
    CancelTimer(E_TmrId_Rtd_T105) ;
}
示例#29
0
void ML::T102TimerStop(void)
{
    CancelTimer(E_TmrId_Ml_T102) ;
}
示例#30
0
void
ThreadTimeUserTimer::Schedule(bigtime_t nextTime, bigtime_t interval,
	uint32 flags, bigtime_t& _oldRemainingTime, bigtime_t& _oldInterval)
{
	InterruptsWriteSequentialLocker locker(sUserTimerLock);
	SpinLocker timeLocker(fThread->time_lock);

	// get the current time, but only if needed
	bool nowValid = fThread != NULL;
	bigtime_t now = nowValid ? fThread->CPUTime(false) : 0;

	// Cancel the old timer, if still scheduled, and get the previous values.
	if (fThread != NULL) {
		if (fScheduled) {
			CancelTimer();
			fScheduled = false;
		}

		_oldRemainingTime = fNextTime - now;
		_oldInterval = fInterval;

		fThread->UserTimerDeactivated(this);
		fThread->ReleaseReference();
		fThread = NULL;
	} else {
		_oldRemainingTime = B_INFINITE_TIMEOUT;
		_oldInterval = 0;
	}

	// schedule the new timer
	fNextTime = nextTime;
	fInterval = interval;
	fOverrunCount = 0;

	if (fNextTime == B_INFINITE_TIMEOUT)
		return;

	// Get the thread. If it doesn't exist anymore, just don't schedule the
	// timer anymore.
	Thread* newThread = Thread::Get(fThreadID);
	if (newThread == NULL) {
		fThread = NULL;
		return;
	} else if (fThread == NULL)
		timeLocker.SetTo(newThread->time_lock, false);
	fThread = newThread;

	fAbsolute = (flags & B_RELATIVE_TIMEOUT) == 0;

	// convert relative to absolute timeouts
	if (!fAbsolute) {
		if (!nowValid)
			now = fThread->CPUTime(false);
		fNextTime += now;
	}

	fThread->UserTimerActivated(this);

	// If the thread is currently running, also schedule a kernel timer.
	if (fThread->cpu != NULL)
		Start();
}