• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RS_UNMARSHAL_THREAD_H
17 #define RS_UNMARSHAL_THREAD_H
18 
19 #include <mutex>
20 
21 #include "event_handler.h"
22 #include "message_parcel.h"
23 
24 #include "transaction/rs_transaction_data.h"
25 
26 namespace OHOS::Rosen {
27 class RSUnmarshalThread {
28 public:
29     static RSUnmarshalThread& Instance();
30     void Start();
31     void PostTask(const std::function<void()>& task);
32     void RecvParcel(std::shared_ptr<MessageParcel>& parcel);
33     TransactionDataMap GetCachedTransactionData();
34 
35 private:
36     RSUnmarshalThread() = default;
37     ~RSUnmarshalThread() = default;
38     RSUnmarshalThread(const RSUnmarshalThread&);
39     RSUnmarshalThread(const RSUnmarshalThread&&);
40     RSUnmarshalThread& operator=(const RSUnmarshalThread&);
41     RSUnmarshalThread& operator=(const RSUnmarshalThread&&);
42 
43     std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
44     std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
45 
46     std::mutex transactionDataMutex_;
47     TransactionDataMap cachedTransactionDataMap_;
48 };
49 }
50 #endif // RS_UNMARSHAL_THREAD_H
51