From 04846a4b77f66121ac02787f998d3585fe20c9a6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 21 Feb 2026 11:12:13 +0100 Subject: chore: allocator_op.hpp: add mutex_type and lock_type. Signed-off-by: Amlal El Mahrouss --- include/ocl/allocator_op.hpp | 16 +++++++++++++--- include/ocl/commit.hpp | 12 ++++++------ include/ocl/crc_hash.hpp | 2 +- include/ocl/equiv.hpp | 1 - 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 #include +#include +#include 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 m_; auto alloc() -> pointer_type { @@ -69,13 +75,17 @@ namespace ocl template auto construct_var(var_type&&... args) { - return std::shared_ptr(allocator_new{}.template var_alloc(std::forward(args)...), allocator_delete{}); + allocator_new alloc; + typename allocator_new::lock_type lt{alloc.m_}; + return std::shared_ptr(alloc.template var_alloc(std::forward(args)...), allocator_delete{}); } template auto construct_array() { - return std::shared_ptr(allocator_new{}.template array_alloc(), allocator_delete{}); + allocator_new alloc; + typename allocator_new::lock_type lt{alloc.m_}; + return std::shared_ptr(alloc.template array_alloc(), 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 -namespace ocl { +namespace ocl +{ - /// @brief Conforms to the IOAble container requirements. - template - class transaction; - + /// @brief Conforms to the IOAble container requirements. + template + 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 using equiv_to_bool = equiv_to; - } // namespace ocl -- cgit v1.2.3