forked from alpaka-group/alpaka3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle.cpp
More file actions
42 lines (34 loc) · 997 Bytes
/
handle.cpp
File metadata and controls
42 lines (34 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Copyright 2024 René Widera
* SPDX-License-Identifier: MPL-2.0
*/
#include "alpaka/onHost/Handle.hpp"
#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cstdint>
using namespace alpaka;
using namespace alpaka::onHost;
struct Count
{
Count(uint32_t value) : m_count(value)
{
}
uint32_t m_count = 0u;
};
using CountHandle = Handle<Count>;
TEST_CASE("singelton handle", "")
{
{
auto singleton = make_sharedSingleton<Count>(42);
CHECK(singleton->m_count == 42);
/* We have already a valid handle therefore the old should be returned.
* This handle is only an alias.
*/
auto singleton2 = make_sharedSingleton<Count>(43);
CHECK(singleton->m_count == 42);
singleton2->m_count = 1;
CHECK(singleton->m_count == 1);
}
// old handles should be deleted
auto singleton = make_sharedSingleton<Count>(23);
CHECK(singleton->m_count == 23);
}