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

Function TEST

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

Source from the content-addressed store, hash-verified

75}
76
77TEST(dmConditionVariable, ProducerConsumer)
78{
79 ThreadArg a;
80 a.m_Mutex = dmMutex::New();
81 a.m_More = dmConditionVariable::New();
82 a.m_Less = dmConditionVariable::New();
83 a.m_Buffer.SetCapacity(16);
84 a.m_Sum = 0;
85
86 dmThread::Thread t1 = dmThread::New(&Producer, 0x80000, &a, "producer");
87 dmThread::Thread t2 = dmThread::New(&Consumer, 0x80000, &a, "consumer");
88
89 dmThread::Join(t1);
90 dmThread::Join(t2);
91 dmMutex::Delete(a.m_Mutex);
92 dmConditionVariable::Delete(a.m_More);
93 dmConditionVariable::Delete(a.m_Less);
94
95 ASSERT_EQ((int64_t) (MAX/2) * (MAX-1), a.m_Sum);
96}
97
98int main(int argc, char **argv)
99{

Callers

nothing calls this directly

Calls 4

NewFunction · 0.50
JoinFunction · 0.50
DeleteFunction · 0.50
SetCapacityMethod · 0.45

Tested by

no test coverage detected