1 /* 2 * Copyright (c) 2024 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 OHOS_DSCHED_COLLABORATION_H 17 #define OHOS_DSCHED_COLLABORATION_H 18 19 #include <cstdint> 20 #include <map> 21 #include <mutex> 22 23 #include "event_handler.h" 24 #include "iremote_object.h" 25 #include "refbase.h" 26 27 #include "distributed_event_died_listener.h" 28 #include "distributed_sched_types.h" 29 30 namespace OHOS { 31 namespace DistributedSchedule { 32 class DSchedCollaborationCallbackMgr : public std::enable_shared_from_this<DSchedCollaborationCallbackMgr> { 33 public: 34 void Init(); 35 bool PushCallback(const sptr<IRemoteObject>& callback); 36 std::vector<sptr<IRemoteObject>> GetCallback(); 37 bool CleanupCallback(const sptr<IRemoteObject>& callback); 38 int32_t NotifyDSchedEventResult(int32_t resultCode, const EventNotify& event); 39 40 private: 41 int32_t NotifyDSchedEventForOneCB(const sptr<IRemoteObject> &cb, const EventNotify& event); 42 43 private: 44 std::mutex collaborateCbLock_; 45 std::vector<sptr<IRemoteObject>> collaborateCbArr_; 46 sptr<DistributedEventDiedListener> diedListener_; 47 }; 48 } // namespace DistributedSchedule 49 } // namespace OHOS 50 #endif // OHOS_DSCHED_COLLABORATION_H 51