1 /*
2  * Copyright (c) 2021-2021 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 HISTREAMER_FOUNDATION_OSAL_MUTEX_H
17 #define HISTREAMER_FOUNDATION_OSAL_MUTEX_H
18 
19 #include <pthread.h>
20 #include <semaphore.h>
21 
22 namespace OHOS {
23 namespace Media {
24 namespace OSAL {
25 class Mutex {
26 public:
27     Mutex();
28 
29     virtual ~Mutex();
30 
31     Mutex(const Mutex&) = delete;
32 
33     Mutex operator=(const Mutex&) = delete;
34 
35     void Lock();
36 
37     bool TryLock();
38 
39     void Unlock();
40 
41 private:
42     pthread_mutex_t nativeHandle_ {};
43     bool created_;
44 
45     friend class ConditionVariable;
46 };
47 } // namespace OSAL
48 } // namespace Media
49 } // namespace OHOS
50 #endif // HISTREAMER_FOUNDATION_OSAL_MUTEX_H
51