Add ecore_wl2_window_commit() when setting minumum size and maximum size.
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / async-task-manager.h
1 #ifndef DALI_ASYNC_TASK_MANAGER_H
2 #define DALI_ASYNC_TASK_MANAGER_H
3
4 /*
5  * Copyright (c) 2022 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 // EXTERNAL INCLUDES
21 #include <dali/public-api/common/intrusive-ptr.h>
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/callback.h>
24 #include <memory>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 namespace Adaptor
34 {
35 class AsyncTaskManager;
36 }
37 } // namespace DALI_INTERNAL
38
39 class AsyncTask;
40 using AsyncTaskPtr = IntrusivePtr<AsyncTask>;
41
42 /**
43  * The async tasks to be processed in the worker thread.
44  * @SINCE_2_2.3
45  */
46 class DALI_ADAPTOR_API AsyncTask : public RefObject
47 {
48 public:
49   /**
50    * Constructor
51    * @SINCE_2_2.3
52    * @param[in] callback The callback to up the main thread. The ownership of callback is taken by this class
53    */
54   AsyncTask(CallbackBase* callback);
55
56   /**
57    * Get the complated callback
58    * @SINCE_2_2.3
59    */
60   CallbackBase* GetCompletedCallback();
61
62   /**
63    * Destructor.
64    * @SINCE_2_2.3
65    */
66   virtual ~AsyncTask() = default;
67
68   /**
69    * Process the task
70    * @SINCE_2_2.3
71    */
72   virtual void Process() = 0;
73
74   /**
75    * Whether the task is ready to process.
76    * @SINCE_2_2.3
77    * @return True if the task is ready to process.
78    */
79   virtual bool IsReady() = 0;
80
81 private:
82   std::unique_ptr<CallbackBase> mCompletedCallback;
83
84   // Undefined
85   AsyncTask(const AsyncTask& task) = delete;
86
87   // Undefined
88   AsyncTask& operator=(const AsyncTask& task) = delete;
89 };
90
91 /**
92  * The manager for async task
93  * @SINCE_2_2.3
94  */
95 class DALI_ADAPTOR_API AsyncTaskManager : public BaseHandle
96 {
97 public:
98   /**
99    * Constructor.
100    * @SINCE_2_2.3
101    */
102   AsyncTaskManager();
103
104   /**
105    * Destructor.
106    * @SINCE_2_2.3
107    */
108   ~AsyncTaskManager();
109
110   /**
111    * @brief Gets the singleton of AsyncTaskManager object.
112    *
113    * @SINCE_2_2.3
114    * @return A handle to the AsyncTaskManager
115    */
116   static AsyncTaskManager Get();
117
118   /**
119    * @brief Add the async task into the waiting queue, called by main thread.
120    *
121    * @SINCE_2_2.3
122    * @param[in] task The task added to the queue.
123    */
124   void AddTask(AsyncTaskPtr task);
125
126   /**
127    * @brief Remove the task from the waiting queue, called by main thread.
128    *
129    * @SINCE_2_2.3
130    * @param[in] task The task pointer.
131    */
132   void RemoveTask(AsyncTaskPtr task);
133
134 public:
135   /// @cond internal
136   /**
137    * @brief Allows the creation of a AsyncTaskManager handle from an internal pointer.
138    *
139    * @note Not intended for application developers
140    * @SINCE_2_2.3
141    * @param[in] impl A pointer to the object
142    */
143   explicit DALI_INTERNAL AsyncTaskManager(Internal::Adaptor::AsyncTaskManager* impl);
144   /// @endcond
145 };
146
147 } // namespace Dali
148
149 #endif