|
KiCad PCB EDA Suite
|
For now, a single process-wide task runner, and one task at a time. More...
#include <api_task_scheduler.h>
Classes | |
| struct | TASK_ENTRY |
Public Member Functions | |
| ~API_TASK_SCHEDULER () override | |
| API_TASK_SCHEDULER (const API_TASK_SCHEDULER &)=delete | |
| API_TASK_SCHEDULER & | operator= (const API_TASK_SCHEDULER &)=delete |
| std::optional< std::string > | StartTask (const std::shared_ptr< API_TASK > &aTask, const wxString &aDescription) |
| Register a new task and begin running it. | |
| std::optional< kiapi::common::tasks::TaskStatusResponse > | GetStatus (const std::string &aToken) const |
| Get a snapshot of the task's current status. | |
| std::shared_ptr< API_TASK > | GetFinishedTask (const std::string &aToken) const |
| Look up a task that has finished, for result retrieval. | |
| bool | AnyTaskRunning () const |
| void | Pump () |
| Run the current task to completion, synchronously. | |
Static Public Member Functions | |
| static API_TASK_SCHEDULER & | Instance () |
Static Public Attributes | |
| static constexpr size_t | MAX_FINISHED_TASKS = 32 |
Private Member Functions | |
| API_TASK_SCHEDULER () | |
| void | onTaskRunEvent (wxCommandEvent &aEvent) |
| void | runTask (const std::string &aToken) |
Private Attributes | |
| std::mutex | m_mutex |
| std::map< std::string, std::shared_ptr< TASK_ENTRY > > | m_tasks |
| std::deque< std::string > | m_finishedTokens |
For now, a single process-wide task runner, and one task at a time.
Definition at line 59 of file api_task_scheduler.h.
|
override |
Definition at line 56 of file api_task_scheduler.cpp.
References onTaskRunEvent().
|
delete |
References API_TASK_SCHEDULER().
Referenced by API_TASK_SCHEDULER(), Instance(), and operator=().
|
private |
Definition at line 50 of file api_task_scheduler.cpp.
References onTaskRunEvent().
| bool API_TASK_SCHEDULER::AnyTaskRunning | ( | ) | const |
Definition at line 149 of file api_task_scheduler.cpp.
References m_mutex, and m_tasks.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and operator=().
| std::shared_ptr< API_TASK > API_TASK_SCHEDULER::GetFinishedTask | ( | const std::string & | aToken | ) | const |
Look up a task that has finished, for result retrieval.
The most recent MAX_FINISHED_TASKS results are available.
Definition at line 136 of file api_task_scheduler.cpp.
References m_mutex, and m_tasks.
Referenced by BOOST_AUTO_TEST_CASE(), API_HANDLER_PCB::handleGetDrcTaskResult(), API_HANDLER_SCH::handleGetErcTaskResult(), and operator=().
| std::optional< kiapi::common::tasks::TaskStatusResponse > API_TASK_SCHEDULER::GetStatus | ( | const std::string & | aToken | ) | const |
Get a snapshot of the task's current status.
Definition at line 91 of file api_task_scheduler.cpp.
References m_mutex, and m_tasks.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), API_HANDLER_PCB::handleGetDrcTaskResult(), API_HANDLER_SCH::handleGetErcTaskResult(), API_HANDLER_COMMON::handleGetTaskStatus(), and operator=().
|
static |
Definition at line 43 of file api_task_scheduler.cpp.
References API_TASK_SCHEDULER().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_API_SERVER::handleApiRequestString(), API_HANDLER_PCB::handleGetDrcTaskResult(), API_HANDLER_SCH::handleGetErcTaskResult(), API_HANDLER_COMMON::handleGetTaskStatus(), API_HANDLER_PCB::handleStartDrcTask(), API_HANDLER_SCH::handleStartErcTask(), and API_HANDLER_PCB::handleStartRefillZonesTask().
|
private |
Definition at line 163 of file api_task_scheduler.cpp.
References runTask().
Referenced by API_TASK_SCHEDULER(), and ~API_TASK_SCHEDULER().
|
delete |
References AnyTaskRunning(), API_TASK_SCHEDULER(), GetFinishedTask(), GetStatus(), Pump(), and StartTask().
| void API_TASK_SCHEDULER::Pump | ( | ) |
Run the current task to completion, synchronously.
The scheduler normally pumps itself via QueueEvent; hosts without a running event loop (unit tests) use this.
Definition at line 238 of file api_task_scheduler.cpp.
References m_mutex, m_tasks, and runTask().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and operator=().
|
private |
Definition at line 172 of file api_task_scheduler.cpp.
References m_finishedTokens, m_mutex, m_tasks, MAX_FINISHED_TASKS, and traceApi.
Referenced by onTaskRunEvent(), and Pump().
| std::optional< std::string > API_TASK_SCHEDULER::StartTask | ( | const std::shared_ptr< API_TASK > & | aTask, |
| const wxString & | aDescription ) |
Register a new task and begin running it.
| aTask | is the task to run |
| aDescription | is used for trace logging |
Definition at line 62 of file api_task_scheduler.cpp.
References KIID::AsStdString(), m_mutex, m_tasks, makeRunEvent(), and traceApi.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), API_HANDLER_PCB::handleStartDrcTask(), API_HANDLER_SCH::handleStartErcTask(), API_HANDLER_PCB::handleStartRefillZonesTask(), and operator=().
|
private |
Definition at line 118 of file api_task_scheduler.h.
Referenced by runTask().
|
mutableprivate |
Definition at line 116 of file api_task_scheduler.h.
Referenced by AnyTaskRunning(), GetFinishedTask(), GetStatus(), Pump(), runTask(), and StartTask().
|
private |
Definition at line 117 of file api_task_scheduler.h.
Referenced by AnyTaskRunning(), GetFinishedTask(), GetStatus(), Pump(), runTask(), and StartTask().
|
staticconstexpr |
Definition at line 62 of file api_task_scheduler.h.
Referenced by BOOST_AUTO_TEST_CASE(), and runTask().