4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
25 m_rw_lock = PTHREAD_RWLOCK_INITIALIZER;
30 pthread_rwlock_destroy(&m_rw_lock);
33 void crw_lock::read_lock()
35 cbase_lock::lock(LOCK_TYPE_READ, "read lock", __MODULE__, __func__, __LINE__);
38 void crw_lock::write_lock()
40 cbase_lock::lock(LOCK_TYPE_WRITE, "write lock", __MODULE__, __func__, __LINE__);
43 int crw_lock::read_lock_impl(void)
45 return pthread_rwlock_rdlock(&m_rw_lock);
47 int crw_lock::write_lock_impl(void)
49 return pthread_rwlock_wrlock(&m_rw_lock);
52 int crw_lock::try_read_lock_impl(void)
54 return pthread_rwlock_tryrdlock(&m_rw_lock);
57 int crw_lock::try_write_lock_impl(void)
59 return pthread_rwlock_trywrlock(&m_rw_lock);
62 int crw_lock::unlock_impl()
64 return pthread_rwlock_unlock(&m_rw_lock);