MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / fixedThreadLocal

Method fixedThreadLocal

Tests/Libraries/Memory/GlobalsTest.cpp:80–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void SC::GlobalsTest::fixedThreadLocal()
81{
82 Thread t1, t2;
83 bool res[2] = {false, false};
84
85 auto threadLocalTest = [&](Thread& thread)
86 {
87 alignas(uint64_t) char stackMemory[48 + sizeof(BufferTL) + sizeof(SmallBufferTL<10>)] = {0};
88 // Every new thread can initialize its set of globals too if different from defaults
89 Globals::init(Globals::ThreadLocal, {1024}); // Available memory for ownership tracker
90 FixedAllocator fixedAllocator = {stackMemory, sizeof(stackMemory)};
91 Globals fixedGlobals = {fixedAllocator};
92 Globals::push(Globals::ThreadLocal, fixedGlobals);
93 bool tRes = testBuffer<BufferTL, SmallBufferTL<10>>(Globals::ThreadLocal);
94 if (&thread == &t1)
95 res[0] = tRes;
96 else
97 res[1] = tRes;
98 Globals::pop(Globals::ThreadLocal);
99 };
100 SC_TEST_EXPECT(t1.start(threadLocalTest));
101 SC_TEST_EXPECT(t2.start(threadLocalTest));
102 SC_TEST_EXPECT(t1.join());
103 SC_TEST_EXPECT(t2.join());
104 SC_TEST_EXPECT(res[0]);
105 SC_TEST_EXPECT(res[1]);
106}
107
108void SC::GlobalsTest::globalsSnippetFixed()
109{

Callers

nothing calls this directly

Calls 3

initFunction · 0.85
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected