MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

valdi/test/runtime/Threading_tests.cpp:19–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include <thread>
18
19using namespace Valdi;
20
21namespace ValdiTest {
22
23TEST(ThreadedDispatchQueue, startsThreadOnFirstTaskEnqueued) {
24 auto dispatchQueue = makeShared<ThreadedDispatchQueue>(STRING_LITERAL("Test Queue"), ThreadQoSClassNormal);
25
26 ASSERT_FALSE(dispatchQueue->hasThreadRunning());
27
28 bool didRun = false;
29 dispatchQueue->sync([&]() { didRun = true; });
30
31 ASSERT_TRUE(didRun);
32 // Sync calls should not trigger the thread creation
33 ASSERT_FALSE(dispatchQueue->hasThreadRunning());
34
35 dispatchQueue->async([]() {});
36
37 ASSERT_TRUE(dispatchQueue->hasThreadRunning());

Callers

nothing calls this directly

Calls 13

hasThreadRunningMethod · 0.80
barrierMethod · 0.80
ownsMethod · 0.80
cancelMethod · 0.65
valueMethod · 0.65
nowFunction · 0.50
createFunction · 0.50
syncMethod · 0.45
asyncMethod · 0.45
enqueueMethod · 0.45
runNextTaskMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected