| 78 | } |
| 79 | |
| 80 | void 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 | |
| 108 | void SC::GlobalsTest::globalsSnippetFixed() |
| 109 | { |