| 32 | static const int MAX = 15000; |
| 33 | |
| 34 | static 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 | |
| 55 | static void Consumer(void* arg) |
| 56 | { |