summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-02-21 11:12:13 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-02-21 11:12:13 +0100
commit04846a4b77f66121ac02787f998d3585fe20c9a6 (patch)
treeaf5ba8139ead614e31c26355986ab958086dfc14 /include
parent0faf648fbd10d8f3623388cefb059faff880179b (diff)
chore: allocator_op.hpp: add mutex_type and lock_type.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/ocl/allocator_op.hpp16
-rw-r--r--include/ocl/commit.hpp12
-rw-r--r--include/ocl/crc_hash.hpp2
-rw-r--r--include/ocl/equiv.hpp1
4 files changed, 20 insertions, 11 deletions
diff --git a/include/ocl/allocator_op.hpp b/include/ocl/allocator_op.hpp
index 85648ca..f03edc9 100644
--- a/include/ocl/allocator_op.hpp
+++ b/include/ocl/allocator_op.hpp
@@ -1,4 +1,4 @@
-// Copyright 2025, Amlal El Mahrouss (amlal@nekernel.org)
+// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Official repository: https://github.com/ocl-org/core
@@ -8,6 +8,8 @@
#include <ocl/detail/config.hpp>
#include <memory>
+#include <mutex>
+#include <thread>
namespace ocl
{
@@ -20,6 +22,10 @@ namespace ocl
using const_pointer_type = const type*;
using pointer = type*;
using const_pointer = const type*;
+ using mutex_type = std::mutex;
+ using lock_type = std::scoped_lock<mutex_type>;
+
+ mutex_type m_;
auto alloc() -> pointer_type
{
@@ -69,13 +75,17 @@ namespace ocl
template <typename... var_type>
auto construct_var(var_type&&... args)
{
- return std::shared_ptr<ret_type>(allocator_new{}.template var_alloc<var_type...>(std::forward<var_type...>(args)...), allocator_delete{});
+ allocator_new alloc;
+ typename allocator_new::lock_type lt{alloc.m_};
+ return std::shared_ptr<ret_type>(alloc.template var_alloc<var_type...>(std::forward<var_type...>(args)...), allocator_delete{});
}
template <std::size_t N>
auto construct_array()
{
- return std::shared_ptr<ret_type>(allocator_new{}.template array_alloc<N>(), allocator_delete{});
+ allocator_new alloc;
+ typename allocator_new::lock_type lt{alloc.m_};
+ return std::shared_ptr<ret_type>(alloc.template array_alloc<N>(), allocator_delete{});
}
};
diff --git a/include/ocl/commit.hpp b/include/ocl/commit.hpp
index 5638aff..3010907 100644
--- a/include/ocl/commit.hpp
+++ b/include/ocl/commit.hpp
@@ -8,13 +8,13 @@
#include <ocl/detail/config.hpp>
-namespace ocl {
+namespace ocl
+{
- /// @brief Conforms to the IOAble container requirements.
- template <class IOAble>
- class transaction;
-
+ /// @brief Conforms to the IOAble container requirements.
+ template <class IOAble>
+ class transaction;
-}
+} // namespace ocl
#endif
diff --git a/include/ocl/crc_hash.hpp b/include/ocl/crc_hash.hpp
index 9af8819..8c0f93c 100644
--- a/include/ocl/crc_hash.hpp
+++ b/include/ocl/crc_hash.hpp
@@ -62,7 +62,7 @@ namespace ocl
if (!len)
return 0UL;
- Algorithm crc = 0xffffffff;
+ Algorithm crc = 0xffffffff;
std::size_t cnt = 0;
while ((len--) > 0)
diff --git a/include/ocl/equiv.hpp b/include/ocl/equiv.hpp
index b2c65e5..efc6b4f 100644
--- a/include/ocl/equiv.hpp
+++ b/include/ocl/equiv.hpp
@@ -49,7 +49,6 @@ namespace ocl
/// \brief alias equiv_to to boolean type.
template <typename T>
using equiv_to_bool = equiv_to<bool, T>;
-
} // namespace ocl