From 5f7bd02fdec9f922962725aafd8fdb4fa7955cd2 Mon Sep 17 00:00:00 2001 From: Jaesung Ku Date: Mon, 24 Jun 2013 22:46:48 +0900 Subject: [PATCH] Update for log and documentation Change-Id: I1ae861dfefb0056b35c730d9b780ff42bdba06b2 Signed-off-by: Jaesung Ku --- inc/FBaseRtEvent.h | 6 +++++- inc/FBaseRtTimer.h | 35 ++++++++++++++++++---------------- src/base/runtime/FBaseRt_TimerImpl.cpp | 27 ++++++++++++++------------ 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/inc/FBaseRtEvent.h b/inc/FBaseRtEvent.h index 59581f3..2f4501b 100644 --- a/inc/FBaseRtEvent.h +++ b/inc/FBaseRtEvent.h @@ -33,9 +33,13 @@ class IEventArg; class IEventListener; /** * @class Event -* @brief This class provides methods for delivering an event with an argument synchronously and asynchronously. +* @brief This class provides methods for notifying events with argument to its listeners. * @since 2.0 * +* The %Event class provides methods for notifying events with argument to its listeners. +* Because bounded to either default thread or event-driven thread, it cannot be created on worker thread. +* It supports two types of listeners; one is called on the thread where the event is fired, and another is called on the thread where the listener was registered. +* * @code * * #include diff --git a/inc/FBaseRtTimer.h b/inc/FBaseRtTimer.h index 1fc0932..1008b0d 100644 --- a/inc/FBaseRtTimer.h +++ b/inc/FBaseRtTimer.h @@ -38,6 +38,8 @@ namespace Tizen { namespace Base { namespace Runtime * @since 2.0 * * The %Timer class can activate the timer and notify the listeners. + * It supports relative time and provides both repeatable and non-repeatable timer. + * Because Timer is handled by event-driven way, when the main loop gets blocked, even if the time is expired, the listener cannot get notified. * Once the target goes into sleep mode, Timer does not work properly because the main loop gets stopped. * You can use Alarm on behalf of Timer for sleep mode. * For more information on the class features, see Timer. @@ -139,8 +141,8 @@ public: * @since 2.0 * * @return An error code - * @param[in] listener The event listener - * @exception E_SUCCESS The method is successful. + * @param[in] listener The event listener + * @exception E_SUCCESS The method is successful. * @exception E_OUT_OF_MEMORY The memory is insufficient. * @exception E_SYSTEM A system error has occurred. */ @@ -149,25 +151,25 @@ public: /** * Starts the timer. * - * @if OSPCOMPACT + * @if OSPCOMPAT * @brief [Compatibility] * @endif * * @since 2.0 * - * @if OSPCOMPACT + * @if OSPCOMPAT * @compatibility This method has compatibility issues with %Tizen API versions @b prior @b to @b 2.1. @n * For more information, see @ref CompTimerStartPage "here". * @endif * - * @return An error code + * @return An error code * @param[in] timeout A timeout interval in milliseconds - * @exception E_SUCCESS The method is successful. + * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The timer is in an invalid state for start. * @exception E_SYSTEM A system error has occurred. - * @remarks Once it has been started, it cannot be started again until it expires. @n - * You must cancel it if you want to re-start the timer. - * @see Cancel() + * @remarks Once the timer has been started, it cannot be started again until expired. + * @see Cancel() */ result Start(int timeout); @@ -184,17 +186,18 @@ public: /** * Starts the timer. @n - * The timer is expired repeatedly until it is canceled. + * The timer is expired repeatedly until canceled. * * @since 2.0 * - * @return An error code + * @return An error code * @param[in] interval A timeout interval in milliseconds * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The timer is in an invalid state for start. * @exception E_SYSTEM A system error has occurred. - * @remarks To stop timer expiration or restart a timer, the timer must be canceled. - * @see Cancel() + * @remarks To stop timer expiration or restart a timer, the timer must be canceled. + * @see Cancel() */ result StartAsRepeatable(int interval); @@ -203,10 +206,10 @@ public: * * @since 2.0 * - * @return An error code - * @exception E_SUCCESS The method is successful. + * @return An error code + * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. - * @remarks The timer cannot be canceled if it is not started. + * @remarks The started timer can be canceled when it does not get expired. If the timer was already expired, this method also returns E_SUCCESS which affects the same manner when canceled normally. */ result Cancel(void); diff --git a/src/base/runtime/FBaseRt_TimerImpl.cpp b/src/base/runtime/FBaseRt_TimerImpl.cpp index 3dbbc8a..f1159bc 100644 --- a/src/base/runtime/FBaseRt_TimerImpl.cpp +++ b/src/base/runtime/FBaseRt_TimerImpl.cpp @@ -235,18 +235,21 @@ _TimerImpl::Cancel(void) { int ret = -1; struct itimerspec newTimeout; - SysTryReturnResult(NID_BASE_RT, (__status == TIMER_STATUS_ACTIVATED) || (__status == TIMER_STATUS_ACTIVATED_REPEATABLE), E_INVALID_STATE, "Timer is not started."); - - newTimeout.it_value.tv_sec = 0; - newTimeout.it_value.tv_nsec = 0; - newTimeout.it_interval.tv_sec = 0; - newTimeout.it_interval.tv_nsec = 0; - - ret = timerfd_settime(__timerFd, TFD_TIMER_ABSTIME, &newTimeout, null); - SysTryReturnResult(NID_BASE_RT, ret != -1, E_SYSTEM, "Failed to unset timeout."); - - __status = TIMER_STATUS_CANCELED; - + if ((__status == TIMER_STATUS_ACTIVATED) || (__status == TIMER_STATUS_ACTIVATED_REPEATABLE)) + { + newTimeout.it_value.tv_sec = 0; + newTimeout.it_value.tv_nsec = 0; + newTimeout.it_interval.tv_sec = 0; + newTimeout.it_interval.tv_nsec = 0; + + ret = timerfd_settime(__timerFd, TFD_TIMER_ABSTIME, &newTimeout, null); + SysTryReturnResult(NID_BASE_RT, ret != -1, E_SYSTEM, "Failed to unset timeout."); + __status = TIMER_STATUS_CANCELED; + } + else + { + SysLog(NID_BASE_RT, "The timer is not started."); + } return E_SUCCESS; } -- 2.7.4