f15cf0769f9b0407c085b1d90ba5a50e46e48fc6
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / event-thread-callback.h
1 #ifndef __DALI_EVENT_THREAD_CALLBACK_H_
2 #define __DALI_EVENT_THREAD_CALLBACK_H_
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/signals/callback.h>
24
25 namespace Dali
26 {
27
28 /**
29  * @brief The EventThreadCallback class provides a mechanism for the worker thread to trigger the execution of a given callback in main event thread .
30  *
31  * @note The EventThreadCallback object should only be created in the main thread.
32  */
33 class DALI_IMPORT_API EventThreadCallback
34 {
35 public:
36
37   /**
38    * @brief Constructor. Create an object that will call the given callback in main event thread.
39    *
40    * @param[in] callback The callback to call.
41    */
42   EventThreadCallback( CallbackBase* callback );
43
44   /**
45    * @brief Destructor.
46    */
47   ~EventThreadCallback();
48
49   /**
50    * @brief Trigger the calling of callback.
51    *
52    * The method can be used from worker threads to notify the main thread as main thread is running the event loop and thus cannot be blocked
53    */
54   void Trigger();
55
56 private:
57
58   // undefined copy constructor.
59   EventThreadCallback( const EventThreadCallback& );
60
61   // undefined assignment operator
62   EventThreadCallback& operator=( const EventThreadCallback& );
63
64 private:
65
66   struct Impl;
67   Impl* mImpl;
68
69 };
70
71 }
72 #endif /* __DALI_EVENT_THREAD_CALLBACK_H_ */