/********************************************************************** * * Method: waitfor() * * Description: Wait for the software timer to finish. * * Notes: * * Returns: 0 on success, -1 if the timer is not running. * **********************************************************************/ int Timer::waitfor() { if (state != Active) { return (-1); } // // Wait for the timer to expire. // while (state != Done); timerList.remove(this); // // Restart or idle the timer, depending on its type. // if (type == Periodic) { state = Active; timerList.insert(this); } else { state = Idle; } return (0); } /* waitfor() */
/********************************************************************** * * Method: isDone() * * Description: check for the software timer to finish. * * Notes: * * Returns: 1 on success, 0 if the timer is running. * **********************************************************************/ int Timer::isDone() { #if 0 if (state != Active) { return (-1); } #endif // // Wait for the timer to expire. // if (state != Done) return 0; timerList.remove(this); // // Restart or idle the timer, depending on its type. // if (type == Periodic) { state = Active; timerList.insert(this); } else { state = Idle; } return 1; } /* isDone() */
/********************************************************************** * * Method: cancel() * * Description: Stop a running timer. * * Notes: * * Returns: None defined. * **********************************************************************/ void Timer::cancel(void) { // // Remove the timer from the timer list. // if (state == Active) { timerList.remove(this); } // // Reset the timer's state. // state = Idle; } /* cancel() */