MCPcopy Create free account
hub / github.com/Tracktion/choc / start

Method start

choc/threading/choc_TaskThread.h:105–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103inline TaskThread::~TaskThread() { stop(); }
104
105inline void TaskThread::start (uint32_t repeatIntervalMillisecs, std::function<void()> f)
106{
107 CHOC_ASSERT (f != nullptr);
108
109 stop();
110 taskFunction = std::move (f);
111 interval = repeatIntervalMillisecs;
112 threadShouldExit = false;
113 flag.test_and_set (std::memory_order_acquire);
114
115 thread = std::thread ([this]
116 {
117 wait();
118
119 while (! threadShouldExit)
120 {
121 taskFunction();
122 wait();
123 }
124 });
125}
126
127template<typename Rep, typename Period>
128void TaskThread::start (std::chrono::duration<Rep, Period> i, std::function<void()> task)

Callers 4

PimplMethod · 0.45
testThreadingFunction · 0.45
choc_tests.hFile · 0.45
demonstrateTaskThreadFunction · 0.45

Calls 2

startFunction · 0.85
stopFunction · 0.50

Tested by 1

testThreadingFunction · 0.36