![]() |
Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
|
The TaskScheduler is responsible for managing tasks and threads. More...
#include <duckdb.hpp>

Public Member Functions | |
| TaskScheduler (DatabaseInstance &db) | |
| unique_ptr< ProducerToken > | CreateProducer () |
| void | ScheduleTask (ProducerToken &producer, shared_ptr< Task > task) |
| Schedule a task to be executed by the task scheduler. | |
| void | ScheduleTasks (ProducerToken &producer, vector< shared_ptr< Task > > &tasks) |
| bool | GetTaskFromProducer (ProducerToken &token, shared_ptr< Task > &task) |
| Fetches a task from a specific producer, returns true if successful or false if no tasks were available. | |
| void | ExecuteForever (atomic< bool > *marker) |
| Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined. | |
| idx_t | ExecuteTasks (atomic< bool > *marker, idx_t max_tasks) |
| void | ExecuteTasks (idx_t max_tasks) |
Run tasks until max_tasks have been completed, or until there are no more tasks available. | |
| void | SetThreads (idx_t total_threads, idx_t external_threads) |
| void | RelaunchThreads () |
| DUCKDB_API int32_t | NumberOfThreads () |
| Returns the number of threads. | |
| idx_t | GetNumberOfTasks () const |
| idx_t | GetProducerCount () const |
| idx_t | GetTaskCountForProducer (ProducerToken &token) const |
| void | Signal (idx_t n) |
| Send signals to n threads, signalling for them to wake up and attempt to execute a task. | |
| void | SetAllocatorFlushTreshold (idx_t threshold) |
| Set the allocator flush threshold. | |
| void | SetAllocatorBackgroundThreads (bool enable) |
| Sets the allocator background thread. | |
Static Public Member Functions | |
| static DUCKDB_API TaskScheduler & | GetScheduler (ClientContext &context) |
| static DUCKDB_API TaskScheduler & | GetScheduler (DatabaseInstance &db) |
| static void | YieldThread () |
| Yield to other threads. | |
| static idx_t | GetEstimatedCPUId () |
Private Member Functions | |
| void | RelaunchThreadsInternal (int32_t n, bool destroy) |
Private Attributes | |
| DatabaseInstance & | db |
| unique_ptr< ConcurrentQueue > | queue |
| The task queue. | |
| mutex | thread_lock |
| Lock for modifying the thread count. | |
| vector< unique_ptr< SchedulerThread > > | threads |
| The active background threads of the task scheduler. | |
| vector< unique_ptr< atomic< bool > > > | markers |
| Markers used by the various threads, if the markers are set to "false" the thread execution is stopped. | |
| atomic< idx_t > | allocator_flush_threshold |
| The threshold after which to flush the allocator after completing a task. | |
| atomic< bool > | allocator_background_threads |
| Whether allocator background threads are enabled. | |
| atomic< int32_t > | requested_thread_count |
| Requested thread count (set by the 'threads' setting) | |
| atomic< int32_t > | current_thread_count |
| The amount of threads currently running. | |
Static Private Attributes | |
| static constexpr int64_t | TASK_TIMEOUT_USECS = 5000 |
The TaskScheduler is responsible for managing tasks and threads.
Run tasks until marker is set to false, max_tasks have been completed, or until there are no more tasks available. Returns the number of tasks that were completed.
Sets the amount of background threads to be used for execution, based on the number of total threads and the number of external threads. External threads, e.g. the main thread, will also be used for execution. Launches total_threads - external_threads background worker threads.
Get the number of the CPU on which the calling thread is currently executing. Fallback to calling thread id if CPU number is not available. Result do not need to be exact 'return 0' is a valid fallback strategy