dispenso
1.6.0
A library for task parallelism
Loading...
Searching...
No Matches
distributed_rw_lock.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) Meta Platforms, Inc. and affiliates.
3
*
4
* This source code is licensed under the MIT license found in the
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
#pragma once
9
63
#include <dispenso/detail/distributed_rw_lock_impl.h>
64
#include <
dispenso/thread_id.h
>
65
66
namespace
dispenso {
67
88
template
<
size_t
N = 16>
89
class
alignas(kCacheLineSize)
DistributedRWLock
{
90
public
:
92
void
lock_shared
() {
93
impl_.lock_shared(
static_cast<
size_t
>
(
threadId
()));
94
}
95
97
void
unlock_shared
() {
98
impl_.unlock_shared(
static_cast<
size_t
>
(
threadId
()));
99
}
100
103
bool
try_lock_shared
() {
104
return
impl_.try_lock_shared(
static_cast<
size_t
>
(
threadId
()));
105
}
106
108
void
lock
() {
109
impl_.lock();
110
}
111
114
bool
try_lock
() {
115
return
impl_.try_lock();
116
}
117
119
void
unlock
() {
120
impl_.unlock();
121
}
122
123
private
:
124
detail::DistributedRWLockImpl<N> impl_;
125
};
126
127
}
// namespace dispenso
dispenso::DistributedRWLock
Definition
distributed_rw_lock.h:89
dispenso::DistributedRWLock::unlock
void unlock()
Definition
distributed_rw_lock.h:119
dispenso::DistributedRWLock::try_lock_shared
bool try_lock_shared()
Definition
distributed_rw_lock.h:103
dispenso::DistributedRWLock::lock_shared
void lock_shared()
Definition
distributed_rw_lock.h:92
dispenso::DistributedRWLock::try_lock
bool try_lock()
Definition
distributed_rw_lock.h:114
dispenso::DistributedRWLock::unlock_shared
void unlock_shared()
Definition
distributed_rw_lock.h:97
dispenso::DistributedRWLock::lock
void lock()
Definition
distributed_rw_lock.h:108
thread_id.h
dispenso::threadId
DISPENSO_DLL_ACCESS uint64_t threadId()
dispenso
distributed_rw_lock.h
Generated by
1.12.0