| 123 | { |
| 124 | public: |
| 125 | WorkQueue2( size_t totalWorkerCount, size_t activeWorkersCount, Processor processor ) : |
| 126 | m_processor( processor ) |
| 127 | { |
| 128 | m_totalWorkerCount = totalWorkerCount; |
| 129 | m_activeWorkersCount = activeWorkersCount; |
| 130 | |
| 131 | #ifdef __APPLE__ |
| 132 | semaphore_create( current_task(), &m_activeWorkersSemaphore, SYNC_POLICY_FIFO, (int32_t)activeWorkersCount ); |
| 133 | #else |
| 134 | m_activeWorkersSemaphore = CreateSemaphore( NULL, (long)activeWorkersCount, (long)activeWorkersCount, NULL ); |
| 135 | if( m_activeWorkersSemaphore == NULL ) |
| 136 | { |
| 137 | g_messages.AddMessage( "WorkQueue2: Creating m_activeWorkersSemaphore failed! Error: %d", GetLastError() ); |
| 138 | } |
| 139 | #endif |
| 140 | started = false; |
| 141 | |
| 142 | for( size_t i = 0; i < totalWorkerCount; ++i ) |
| 143 | { |
| 144 | m_workerThreads.emplace_back( std::thread( [this] { WorkerThread(); } ) ); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | virtual ~WorkQueue2() |
| 149 | { |
nothing calls this directly
no test coverage detected