Add GetCallbackInvocationThread() for AsyncTaskMananager
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / async-task-manager.h
index 02021c1..dd3ebc0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ASYNC_TASK_MANAGER_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,12 +46,20 @@ using AsyncTaskPtr = IntrusivePtr<AsyncTask>;
 class DALI_ADAPTOR_API AsyncTask : public RefObject
 {
 public:
+  // The Type of invocation thread
+  enum class ThreadType
+  {
+    MAIN_THREAD,
+    WORKER_THREAD
+  };
+
   /**
    * Constructor
    * @SINCE_2_2.3
-   * @param[in] callback The callback to up the main thread. The ownership of callback is taken by this class
+   * @param[in] callback The callback to invoke on task completion, either on the main thread on the worker thread. The ownership of callback is taken by this class.
+   * @param[in] threadType The thread type of invocation callback.
    */
-  AsyncTask(CallbackBase* callback);
+  AsyncTask(CallbackBase* callback, ThreadType threadType = AsyncTask::ThreadType::MAIN_THREAD);
 
   /**
    * Get the complated callback
@@ -60,6 +68,13 @@ public:
   CallbackBase* GetCompletedCallback();
 
   /**
+   * Get the thread of the invocation callback
+   * @SINCE_2_2.9
+   * @return the type of invocation callback.
+   */
+  ThreadType GetCallbackInvocationThread();
+
+  /**
    * Destructor.
    * @SINCE_2_2.3
    */
@@ -80,6 +95,7 @@ public:
 
 private:
   std::unique_ptr<CallbackBase> mCompletedCallback;
+  ThreadType                    mThreadType;
 
   // Undefined
   AsyncTask(const AsyncTask& task) = delete;