1 /* 2 * Copyright (C) 2025-2025 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 #ifndef MOCK_FFRT_API_CPP_MUTEX_H 16 #define MOCK_FFRT_API_CPP_MUTEX_H 17 18 #include "c/mutex.h" 19 20 namespace ffrt { 21 22 class mutex : public ffrt_mutex_t { 23 public: mutex()24 mutex() 25 {} 26 ~mutex()27 ~mutex() 28 { 29 } 30 31 mutex(const mutex &) = delete; 32 33 void operator=(const mutex &) = delete; 34 try_lock()35 inline bool try_lock() 36 { 37 return true; 38 } 39 lock()40 inline void lock() 41 {} 42 unlock()43 inline void unlock() 44 {} 45 }; 46 47 class recursive_mutex : public ffrt_mutex_t { 48 public: recursive_mutex()49 recursive_mutex() 50 {} 51 ~recursive_mutex()52 ~recursive_mutex() 53 {} 54 55 recursive_mutex(const recursive_mutex &) = delete; 56 57 void operator=(const recursive_mutex &) = delete; 58 try_lock()59 inline bool try_lock() 60 { 61 return true; 62 } 63 lock()64 inline void lock() 65 {} 66 unlock()67 inline void unlock() 68 {} 69 }; 70 } // namespace ffrt 71 72 #endif