1 /* 2 * Copyright (c) 2023 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 CLOUD_LOCKER_H 17 #define CLOUD_LOCKER_H 18 #include <memory> 19 #include "icloud_syncer.h" 20 namespace DistributedDB { 21 using AfterBuildAction = std::function<int()>; 22 using BeforeFinalize = std::function<void()>; 23 class CloudLocker final { 24 public: 25 static int BuildCloudLock(const AfterBuildAction &buildAction, const BeforeFinalize &finalize, 26 std::shared_ptr<CloudLocker> &locker); 27 CloudLocker() = default; 28 ~CloudLocker(); 29 private: 30 BeforeFinalize finalize_; 31 }; 32 } 33 #endif // CLOUD_LOCKER_H