|
KiCad PCB EDA Suite
|
A helper class to execute tasks on a thread pool in priority order, with progress reporting. More...
#include <priority_thread_pool_task.h>
Public Types | |
| using | ItemT = typename ContainerT::value_type |
Public Member Functions | |
| PRIORITY_THREAD_POOL_TASK () | |
| void | SetReporter (PROGRESS_REPORTER *aReporter) |
| void | Execute (ContainerT &aItems) |
| Call this to execute the task on all items in aItems, using the thread pool and dispatching the tasks in order of descending priority as determined by comparePriority() implemented by the derived class. | |
Protected Attributes | |
| PROGRESS_REPORTER * | m_reporter |
Private Member Functions | |
| virtual int | computePriorityKey (const ItemT &aItem) const =0 |
| Implement this to compute a priority key for an item. | |
| virtual size_t | task (ItemT &item)=0 |
| Process one item in the thread pool. | |
Private Attributes | |
| BS::priority_t | m_highestPriority |
| std::chrono::milliseconds | m_reporterInterval |
A helper class to execute tasks on a thread pool in priority order, with progress reporting.
Definition at line 33 of file priority_thread_pool_task.h.
| using PRIORITY_THREAD_POOL_TASK< ContainerT >::ItemT = typename ContainerT::value_type |
Definition at line 36 of file priority_thread_pool_task.h.
|
inline |
Definition at line 38 of file priority_thread_pool_task.h.
References m_highestPriority, m_reporter, and m_reporterInterval.
|
privatepure virtual |
Implement this to compute a priority key for an item.
Return a number representing priority, where a higher number means higher priority. The actual values returned don't matter, only their relative order.
(A relational a < b comparator would work too, but a unary key lets us compute it once per item in O(n) and then sort indices cheaply, rather than calling it O(n log n) times inside std::sort.)
If you'd like to test the effect of this priority ordering, you can return a constant value to disable sorting, or return the inverse to sort backwards.
Referenced by Execute().
|
inline |
Call this to execute the task on all items in aItems, using the thread pool and dispatching the tasks in order of descending priority as determined by comparePriority() implemented by the derived class.
Definition at line 52 of file priority_thread_pool_task.h.
References computePriorityKey(), GetKiCadThreadPool(), m_highestPriority, m_reporter, m_reporterInterval, and tp.
Referenced by ALLEGRO::BOARD_BUILDER::ZONE_FILL_HANDLER::ProcessPolygons().
|
inline |
Definition at line 45 of file priority_thread_pool_task.h.
References m_reporter.
|
privatepure virtual |
Process one item in the thread pool.
Return the number of items processed.
|
private |
Definition at line 129 of file priority_thread_pool_task.h.
Referenced by Execute(), and PRIORITY_THREAD_POOL_TASK().
|
protected |
Definition at line 105 of file priority_thread_pool_task.h.
Referenced by Execute(), PRIORITY_THREAD_POOL_TASK(), and SetReporter().
|
private |
Definition at line 130 of file priority_thread_pool_task.h.
Referenced by Execute(), and PRIORITY_THREAD_POOL_TASK().