mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
feat(thread): add basic thread functions
This commit is contained in:
parent
0242759cbe
commit
39f4bd35a3
5 changed files with 296 additions and 0 deletions
21
test/Thread.cpp
Normal file
21
test/Thread.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include "bc/Thread.hpp"
|
||||
#include "bc/Memory.hpp"
|
||||
#include "test/Test.hpp"
|
||||
|
||||
void* ConstructInteger(void* value) {
|
||||
auto ptr = reinterpret_cast<int32_t*>(Blizzard::Memory::Allocate(sizeof(int32_t)));
|
||||
*ptr = *reinterpret_cast<int32_t*>(value);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
TEST_CASE("Blizzard::Thread::RegisterLocalStorage", "[thread]") {
|
||||
SECTION("constructs value and stores it in available TLS slot") {
|
||||
Blizzard::Thread::TLSSlot slot {};
|
||||
Blizzard::Thread::AllocateLocalStorage(&slot);
|
||||
|
||||
int32_t value = 12345;
|
||||
auto ptr = Blizzard::Thread::RegisterLocalStorage(&slot, ConstructInteger, &value, nullptr);
|
||||
|
||||
REQUIRE(*reinterpret_cast<int32_t*>(ptr) == value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue