MCPcopy Create free account
hub / github.com/defold/defold / Producer

Function Producer

engine/dlib/src/test/test_condition_variable.cpp:34–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32static const int MAX = 15000;
33
34static void Producer(void* arg)
35{
36 ThreadArg* a = (ThreadArg*) arg;
37
38 int i = 0;
39 while (i < MAX)
40 {
41 dmMutex::Lock(a->m_Mutex);
42 if (a->m_Buffer.Full() && i < MAX) {
43 dmConditionVariable::Wait(a->m_Less, a->m_Mutex);
44 }
45
46 while (!a->m_Buffer.Full() && i < MAX) {
47 a->m_Buffer.Push(i);
48 i++;
49 }
50 dmConditionVariable::Signal(a->m_More);
51 dmMutex::Unlock(a->m_Mutex);
52 }
53}
54
55static void Consumer(void* arg)
56{

Callers

nothing calls this directly

Calls 6

LockFunction · 0.50
WaitFunction · 0.50
SignalFunction · 0.50
UnlockFunction · 0.50
FullMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected