DPC++ Runtime
Runtime libraries for oneAPI DPC++
locked.hpp
Go to the documentation of this file.
1
//==---------------- locked.hpp - Reference with lock -----------*- C++-*---==//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#pragma once
10
11
#include <
sycl/detail/defines.hpp
>
12
13
#include <functional>
14
#include <mutex>
15
16
namespace
sycl
{
17
__SYCL_INLINE_VER_NAMESPACE
(_V1) {
18
namespace
detail {
23
template
<
typename
T>
class
Locked
{
24
std::reference_wrapper<T> m_Value;
25
std::unique_lock<std::mutex> m_Lock;
26
27
public
:
28
Locked
(T &v, std::mutex &mutex) : m_Value{v}, m_Lock{mutex} {}
29
30
T &
get
()
const
{
return
m_Value.get(); }
31
};
32
}
// namespace detail
33
}
// __SYCL_INLINE_VER_NAMESPACE(_V1)
34
}
// namespace sycl
sycl::_V1::detail::Locked::Locked
Locked(T &v, std::mutex &mutex)
Definition:
locked.hpp:28
sycl::_V1::detail::Locked::get
T & get() const
Definition:
locked.hpp:30
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition:
defines_elementary.hpp:11
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition:
access.hpp:14
defines.hpp
sycl::_V1::detail::Locked
Represents a reference to value with appropriate lock acquired.
Definition:
locked.hpp:23
include
sycl
detail
locked.hpp
Generated by
1.8.17