2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseRtWaitingLoop.h
19 * @brief This is the header file for the %WaitingLoop class.
21 * This file contains the declarations of the %WaitingLoop class.
24 #ifndef _FBASE_RT_WAITING_LOOP_H_
25 #define _FBASE_RT_WAITING_LOOP_H_
27 #include <FBaseObject.h>
28 #include <FBaseRtIWaitingLoopCondition.h>
30 namespace Tizen { namespace Base { namespace Runtime
33 class IWaitingLoopCondition;
36 * @brief This class allows developers to make the current thread wait for callback events. This class should be used only for test codes and don't use this class for commercial applications
39 * @final This class is not intended for extension.
41 class _OSP_EXPORT_ WaitingLoop
42 : public Tizen::Base::Object
46 * Gets the WaitingLoop instance.
50 * @return A pointer to the WaitingLoop instance, @n
51 * else @c null if it fails
52 * @remarks Once the WaitingLoop instance has been created, you must not use the instance between threads. Especially, the methods for waiting should be called on the thread you get the instance at first time.
54 static WaitingLoop* GetInstance(void);
57 * Starts the waiting loop and waits until the time is expired.
61 * @param[in] timeout The timeout period in milliseconds
62 * @exception E_SUCCESS The method is successful.
63 * @exception E_TIMEOUT The time is expired.
64 * @exception E_INVALID_STATE The waiting loop has already been waiting on a callback event. In order to wait again, you must quit the waiting loop.
65 * @remarks The timeout set to min(timeout, maximum), where the maximum is set using SetMaxTimeoutForWaiting().
67 * @see SetMaxTimoutForWaiting()
69 result Wait(int timeout);
72 * Starts the waiting loop and waits until the specified condition is met.
76 * @param[in] condition The expiring condition
77 * @exception E_SUCCESS The method is successful.
78 * @exception E_INVALID_STATE The waiting loop has already been waiting on a callback event. In order to wait again, you must quit the waiting loop.
79 * @remarks In order to use this method correctly, you have to implement a class inheriting from %IWaitingLoopCondition.
81 result Wait(IWaitingLoopCondition& condition);
84 * Starts the waiting loop and waits until either the expiring condition occurs or the time is expired.
88 * @param[in] timeout The timeout period in milliseconds
89 * @param[in] condition The expiring condition
90 * @exception E_TIMEOUT The time is expired.
91 * @exception E_INVALID_STATE The waiting loop is waiting on a thread. In order to wait again, you must quit the waiting loop.
92 * @remarks If the timeout is over the maximum, the expired time goes together with the maximum timeout. In order to use this method correctly, you have to implement a class inheriting from %IWaitingLoopCondition interface
94 result Wait(int timeout, IWaitingLoopCondition& condition);
97 * Notify the waiting thread that the related callback has completed the job.
101 * @remarks This method is recommended to use when the waiting condition is not explicitly specified with Wait().
106 * Sets the maximum timeout for waiting.
110 * @param[in] timeout The timeout period in milliseconds
112 * @remarks If the timeout is considered as a small number, it will be replaced with the specified number provided by platform.
114 static void SetMaxTimeoutForWaiting(int timeout);
118 // This default constructor is intentionally declared as private to implement the %Singleton semantic.
125 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
129 WaitingLoop(const WaitingLoop& rhs);
132 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
136 WaitingLoop& operator =(const WaitingLoop& rhs);
139 // This destructor is intentionally declared as private to implement the %Singleton semantic.
143 virtual ~WaitingLoop(void);
145 friend class _WaitingLoopImpl;
146 class _WaitingLoopImpl* __pWaitingLoopImpl;
149 } } } // Tizen::Base::Runtime
151 #endif // _FBASE_RT_WAITING_LOOP_H_