Skip to content

Commit 9cd9576

Browse files
committed
Fixes to source code after the API changes.
1 parent 8ae38d8 commit 9cd9576

File tree

108 files changed

+370
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+370
-472
lines changed

source/code/core/core/public/ice/hash.hxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
/// Copyright 2022 - 2025, Dandielo <dandielo@iceshard.net>
1+
/// Copyright 2022 - 2026, Dandielo <dandielo@iceshard.net>
22
/// SPDX-License-Identifier: MIT
33

44
#pragma once
55
#include <ice/constants.hxx>
66
#include <ice/hash/murmur2.hxx>
77
#include <ice/hash/murmur3.hxx>
8+
#include <ice/utility.hxx>
89

910
namespace ice
1011
{
@@ -52,6 +53,7 @@ namespace ice
5253
template<typename T>
5354
constexpr auto hash(T value) noexcept -> ice::u64
5455
{
56+
static_assert(ice::concepts::EnumOrIntegral<T>);
5557
return static_cast<ice::u64>(value);
5658
}
5759

source/code/core/core/public/ice/utility.hxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,13 @@ namespace ice
104104
);
105105
}
106106

107+
namespace concepts
108+
{
109+
110+
template<typename T>
111+
concept EnumOrIntegral = std::is_enum_v<T>
112+
or (std::is_arithmetic_v<T> && not std::is_floating_point_v<T>);
113+
114+
} // namespace concepts
115+
107116
} // namespace ice

source/code/core/modules/private/module_register.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
/// SPDX-License-Identifier: MIT
33

44
#include <ice/module_register.hxx>
5-
#include <ice/array.hxx>
6-
#include <ice/container/hashmap.hxx>
5+
#include <ice/multi_hashmap.hxx>
76
#include <ice/heap_string.hxx>
87
#include <ice/os/windows.hxx>
98
#include <ice/os/unix.hxx>
109
#include <ice/profiler.hxx>
1110

1211
#include "module_globals.hxx"
1312
#include "module_native.hxx"
13+
#include <ice/hashmap.hxx>
1414

1515
namespace ice
1616
{
@@ -73,7 +73,7 @@ namespace ice
7373

7474
private:
7575
ice::Allocator& _allocator;
76-
ice::HashMap<DefaultModuleEntry> _modules;
76+
ice::MultiHashMap<DefaultModuleEntry> _modules;
7777
ice::Array<ice::native_module::ModuleHandle> _module_handles;
7878
};
7979

@@ -170,15 +170,15 @@ namespace ice
170170
) const noexcept -> ice::u32
171171
{
172172
ice::u32 result = 0;
173-
auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name));
173+
auto it = _modules.find_values(api_name);
174174
while (it != nullptr)
175175
{
176176
ice::ModuleAPI api_ptr;
177177
if (it.value().select_api(ice::stringid_hash(api_name), version, &api_ptr))
178178
{
179179
result += 1;
180180
}
181-
it = ice::multi_hashmap::find_next(_modules, it);
181+
it.next();
182182
}
183183
return result;
184184
}
@@ -202,7 +202,7 @@ namespace ice
202202
}
203203

204204
ice::u32 idx = 0;
205-
auto it = ice::multi_hashmap::find_first(_modules, ice::hash(api_name));
205+
auto it = _modules.find_values(api_name);
206206

207207
ice::u32 const array_size = *inout_array_size;
208208
while (it != nullptr && idx < array_size)
@@ -213,7 +213,7 @@ namespace ice
213213
out_array[idx] = api_ptr;
214214
idx += 1;
215215
}
216-
it = ice::multi_hashmap::find_next(_modules, it);
216+
it.next();
217217
}
218218
return idx > 0;
219219
}
@@ -223,7 +223,7 @@ namespace ice
223223
) noexcept
224224
{
225225
ice::u64 const name_hash = ice::hash(entry.name);
226-
ice::multi_hashmap::insert(_modules, name_hash, entry);
226+
_modules.insert(name_hash, entry);
227227
return true;
228228
}
229229

source/code/core/modules/public/ice/module_register.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#pragma once
55
#include <ice/mem_unique_ptr.hxx>
66
#include <ice/mem_allocator_stack.hxx>
7-
#include <ice/string_types.hxx>
7+
#include <ice/string.hxx>
88
#include <ice/stringid.hxx>
9-
#include <ice/container_types.hxx>
109
#include <ice/array.hxx>
1110
#include <ice/module_negotiator.hxx>
1211
#include <ice/module_query.hxx>

source/code/core/tasks/private/task_native_thread.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace ice
5050
while (_runtime._state != ThreadState::Destroyed)
5151
{
5252
_runtime._queue.push_back(&final_awaitable);
53-
thread_native::sleep(1);
53+
thread_native::sleep(3); // sleep for a few milliseconds to ensure the thread was destroyed
5454
}
5555

5656
thread_native::destroy_thread(_native);

source/code/core/tasks/private/task_thread_pool_impl.cxx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,21 @@ namespace ice
134134
.debug_name = ice::String{ name_hint.data(), static_cast<ice::u32>(name_hint.size()) }
135135
};
136136

137-
ice::hashmap::set(
138-
_created_threads,
139-
ice::hash(name),
137+
_created_threads.set(
138+
name,
140139
ice::make_unique<ice::NativeTaskThread>(
141140
_allocator,
142141
_queue,
143142
thread_info
144143
)
145144
);
146145

147-
return **ice::hashmap::try_get(_created_threads, ice::hash(name));
146+
return **_created_threads.try_get(ice::hash(name));
148147
}
149148

150149
auto TaskThreadPoolImplementation::find_thread(ice::StringID name) noexcept -> ice::TaskThread*
151150
{
152-
if (auto const& unique_ptr = ice::hashmap::try_get(_created_threads, ice::hash(name)))
151+
if (auto const& unique_ptr = _created_threads.try_get(ice::hash(name)))
153152
{
154153
return unique_ptr->get();
155154
}
@@ -158,13 +157,7 @@ namespace ice
158157

159158
bool TaskThreadPoolImplementation::destroy_thread(ice::StringID name) noexcept
160159
{
161-
ice::u64 const name_hash = ice::hash(name);
162-
bool const exists = _created_threads.has(name_hash);
163-
if (exists)
164-
{
165-
ice::hashmap::remove(_created_threads, name_hash);
166-
}
167-
return exists;
160+
return _created_threads.remove(name);
168161
}
169162

170163
auto TaskThreadPoolImplementation::attach_thread(
@@ -173,20 +166,13 @@ namespace ice
173166
ice::UniquePtr<ice::TaskThread> thread
174167
) noexcept -> ice::TaskThread&
175168
{
176-
ice::u64 const name_hash = ice::hash(name);
177169
ICE_ASSERT(
178-
_user_threads.missing(name_hash),
170+
_user_threads.missing(name),
179171
"A user thread with name '{}' already exists",
180172
name
181173
);
182174

183-
ice::hashmap::set(
184-
_user_threads,
185-
name_hash,
186-
ice::move(thread)
187-
);
188-
189-
return **ice::hashmap::try_get(_user_threads, name_hash);
175+
return *_user_threads.set(name, ice::move(thread));
190176
}
191177

192178
auto TaskThreadPoolImplementation::detach_thread(
@@ -198,9 +184,9 @@ namespace ice
198184
if (_user_threads.has(name_hash))
199185
{
200186
// Move the thread out of the map
201-
result = ice::move(*ice::hashmap::try_get(_user_threads, name_hash));
187+
result = ice::move(*_user_threads.try_get(name_hash));
202188
// Remove the element from the map
203-
ice::hashmap::remove(_user_threads, name_hash);
189+
_user_threads.remove(name_hash);
204190
}
205191
return result;
206192
}

source/code/core/tasks/private/task_thread_pool_impl.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <ice/task_thread_pool.hxx>
66
#include <ice/task_flags.hxx>
77
#include <ice/array.hxx>
8-
#include <ice/container/hashmap.hxx>
8+
#include <ice/hashmap.hxx>
99
#include "task_native_thread.hxx"
1010

1111
namespace ice

source/code/core/tasks/public/ice/task_thread.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#pragma once
55
#include <ice/task_types.hxx>
66
#include <ice/mem_unique_ptr.hxx>
7-
#include <ice/string_types.hxx>
7+
#include <ice/string.hxx>
88

99
namespace ice
1010
{

source/code/core/tasks/public/ice/task_thread_pool.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <ice/task_types.hxx>
66
#include <ice/mem_unique_ptr.hxx>
77
#include <ice/native_aio.hxx>
8-
#include <ice/string_types.hxx>
8+
#include <ice/string.hxx>
99
#include <ice/span.hxx>
1010

1111
namespace ice

source/code/core/utils/private/config/config_builder.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// SPDX-License-Identifier: MIT
33

44
#include <ice/config/config_builder.hxx>
5-
#include <ice/container/hashmap.hxx>
5+
#include <ice/multi_hashmap.hxx>
66
#include <ice/heap_string.hxx>
77
#include <ice/heap_varstring.hxx>
88

@@ -47,20 +47,20 @@ namespace ice
4747
ice::u32 offset_strings;
4848
};
4949

50-
auto cb_find_keystr_idx(ice::HashMap<CBKeyString> const& keystrings, ice::String keystr) noexcept -> ice::u32
50+
auto cb_find_keystr_idx(ice::MultiHashMap<CBKeyString> const& keystrings, ice::String keystr) noexcept -> ice::u32
5151
{
5252
ice::u64 const keystr_hash = ice::hash(keystr);
53-
auto it = ice::multi_hashmap::find_first(keystrings, keystr_hash);
53+
auto it = keystrings.find_values(keystr_hash);
5454
while(it != nullptr && it.value().value != keystr)
5555
{
56-
it = ice::multi_hashmap::find_next(keystrings, it);
56+
it.next();
5757
}
5858

5959
return it == nullptr ? keystrings.size().u32() : it.value().index;
6060
}
6161

6262
auto cb_calculate_key_size(
63-
ice::HashMap<CBKeyString>& keystrings,
63+
ice::MultiHashMap<CBKeyString>& keystrings,
6464
ice::config::detail::ConfigBuilderContainer const& config,
6565
ice::config::detail::ConfigBuilderEntry const* entry
6666
) noexcept -> ice::usize
@@ -76,15 +76,15 @@ namespace ice
7676
// This allows us to reuse duplicate key names
7777
if (keystr_idx == keystrings.size())
7878
{
79-
ice::multi_hashmap::insert(keystrings, ice::hash(keystr), { keystr, keystr_idx });
79+
keystrings.insert(keystr, { keystr, keystr_idx });
8080
result += { entry->size }; // Increase the size required
8181
}
8282
}
8383
return result;
8484
}
8585

8686
auto cb_calculate_final_size(
87-
ice::HashMap<CBKeyString>& keystrings,
87+
ice::MultiHashMap<CBKeyString>& keystrings,
8888
ice::config::detail::ConfigBuilderContainer const& config,
8989
ice::usize& out_data_size,
9090
ice::u32& out_count
@@ -138,7 +138,7 @@ namespace ice
138138
}
139139

140140
auto cb_calculate_final_size(
141-
ice::HashMap<CBKeyString>& keystrings,
141+
ice::MultiHashMap<CBKeyString>& keystrings,
142142
ice::config::detail::ConfigBuilderContainer const& config,
143143
ice::u32& out_count
144144
) noexcept -> ice::usize
@@ -157,7 +157,7 @@ namespace ice
157157
}
158158

159159
auto cb_finalize_store_keysvalues(
160-
ice::HashMap<CBKeyString>& keystrings,
160+
ice::MultiHashMap<CBKeyString>& keystrings,
161161
ice::Span<ice::u32 const> keystringoffsets,
162162
ice::config::detail::ConfigBuilderContainer const& config,
163163
ice::config::detail::ConfigKey* out_keylist,
@@ -377,7 +377,7 @@ namespace ice
377377
}
378378

379379
ice::Array<ice::u32> keyoffsets{ alloc };
380-
ice::HashMap<ice::CBKeyString> keystrings{ alloc };
380+
ice::MultiHashMap<ice::CBKeyString> keystrings{ alloc };
381381

382382
ice::u32 final_count = 0;
383383
ice::usize const final_size = cb_calculate_final_size(keystrings, container, final_count);

0 commit comments

Comments
 (0)