vecmem 1.28.0
Loading...
Searching...
No Matches
async_size.ipp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2025-2026 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10// System includes.
11#include <cassert>
12
13namespace vecmem {
14
15template <typename SIZE_TYPE>
17 : m_size{std::move(size)}, m_event{std::move(event)} {}
18
19template <typename SIZE_TYPE>
21
22 // Wait for the event to complete before accessing the value
23 assert(m_event != nullptr);
24 m_event->wait();
25 assert(m_size != nullptr);
26 return (*m_size);
27}
28
29template <typename SIZE_TYPE>
31
32 // Access the value assuming the event is complete
33 assert(m_event != nullptr);
34 assert(m_event->is_ready());
35 m_event->ignore();
36 assert(m_size != nullptr);
37 return (*m_size);
38}
39
40template <typename SIZE_TYPE>
42
43 assert(m_event != nullptr);
44 m_event->wait();
45}
46
47template <typename SIZE_TYPE>
49
50 assert(m_event != nullptr);
51 return m_event->is_ready();
52}
53
54template <typename SIZE_TYPE>
56
57 assert(m_event != nullptr);
58 m_event->ignore();
59}
60
61} // namespace vecmem
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
const_reference unsafe_get() const
Access the async/future value without waiting for completion Completion must be ensured by the user.
Definition async_size.ipp:30
void ignore() override
Function telling the object not to wait for the underlying event.
Definition async_size.ipp:55
std::unique_ptr< abstract_event > event_type
Type of the held event.
Definition async_size.hpp:36
unique_alloc_ptr< size_type > storage_type
Underlying type that stores the size variable on the heap.
Definition async_size.hpp:31
bool is_ready() const override
Function checking whether the event is complete without blocking.
Definition async_size.ipp:48
const_reference get() const
Access the async/future value.
Definition async_size.ipp:20
void wait() override
Function that would block the current thread until the event is complete.
Definition async_size.ipp:41
async_size(storage_type size, event_type event)
Constructor taking ownership of a size and event.
Definition async_size.ipp:16
std::add_lvalue_reference_t< std::add_const_t< size_type > > const_reference
Constant (lvalue) reference to the stored size.
Definition async_size.hpp:34
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16