[dali_2.3.25] Merge branch 'devel/master'
[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) 2020 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/signals/callback.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29 /**
30  * @brief The EventThreadCallback class provides a mechanism for the worker thread to trigger the execution of a given callback in main event thread .
31  *
32  * @note The EventThreadCallback object should only be created in the main thread.
33  */
34 class DALI_ADAPTOR_API EventThreadCallback
35 {
36 public:
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   // undefined copy constructor.
58   EventThreadCallback(const EventThreadCallback&);
59
60   // undefined assignment operator
61   EventThreadCallback& operator=(const EventThreadCallback&);
62
63 private:
64   struct Impl;
65   Impl* mImpl;
66 };
67
68 } // namespace Dali
69 #endif /* DALI_EVENT_THREAD_CALLBACK_H */