MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / TestTicket

Method TestTicket

tests/async/marl-test/ticket_test.cpp:19–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "marl/ticket.h"
18
19void WithBoundSchedulerBase::TestTicket()
20{
21 marl::Ticket::Queue queue;
22
23 constexpr int count = 1000;
24 std::atomic<int> next = {0};
25 int result[count] = {};
26
27 for (int i = 0; i < count; i++) {
28 auto ticket = queue.take();
29 marl::schedule([ticket, i, &result, &next] {
30 ticket.wait();
31 result[next++] = i;
32 ticket.done();
33 });
34 }
35
36 queue.take().wait();
37
38 for (int i = 0; i < count; i++) {
39 ASSERT_EQ(result[i], i);
40 }
41}
42
43TEST_CASE_METHOD(WithBoundScheduler<0>, "TestTicket-0") { TestTicket(); };
44TEST_CASE_METHOD(WithBoundScheduler<1>, "TestTicket-1") { TestTicket(); };

Callers

nothing calls this directly

Calls 3

scheduleFunction · 0.50
waitMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected