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

Method job_thread

engine/dlib/src/basis/encoder/basisu_enc.cpp:1588–1628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1586 }
1587
1588 void job_pool::job_thread(uint32_t index)
1589 {
1590 BASISU_NOTE_UNUSED(index);
1591 //debug_printf("job_pool::job_thread: starting %u\n", index);
1592
1593 while (true)
1594 {
1595 std::unique_lock<std::mutex> lock(m_mutex);
1596
1597 // Wait for any jobs to be issued.
1598 m_has_work.wait(lock, [this] { return m_kill_flag || m_queue.size(); } );
1599
1600 // Check to see if we're supposed to exit.
1601 if (m_kill_flag)
1602 break;
1603
1604 // Get the job and execute it.
1605 std::function<void()> job(m_queue.back());
1606 m_queue.pop_back();
1607
1608 ++m_num_active_jobs;
1609
1610 lock.unlock();
1611
1612 job();
1613
1614 lock.lock();
1615
1616 --m_num_active_jobs;
1617
1618 // Now check if there are no more jobs remaining.
1619 const bool all_done = m_queue.empty() && !m_num_active_jobs;
1620
1621 lock.unlock();
1622
1623 if (all_done)
1624 m_no_more_jobs.notify_all();
1625 }
1626
1627 //debug_printf("job_pool::job_thread: exiting\n");
1628 }
1629
1630 // .TGA image loading
1631 #pragma pack(push)

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
pop_backMethod · 0.45
unlockMethod · 0.45
lockMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected