diff options
Diffstat (limited to 'include/framework/scheduling/Task.h')
| -rw-r--r-- | include/framework/scheduling/Task.h | 101 |
1 files changed, 50 insertions, 51 deletions
diff --git a/include/framework/scheduling/Task.h b/include/framework/scheduling/Task.h index bd53090..6b6f040 100644 --- a/include/framework/scheduling/Task.h +++ b/include/framework/scheduling/Task.h @@ -1,7 +1,7 @@ /* * include/framework/scheduling/Task.h * - * Copyright (C) 2023 Douglas B. Rumbaugh <drumbaugh@psu.edu> + * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu> * * Distributed under the Modified BSD License. * @@ -13,77 +13,76 @@ */ #pragma once -#include <future> -#include <functional> #include <chrono> +#include <functional> +#include <future> -#include "framework/util/Configuration.h" #include "framework/scheduling/Epoch.h" #include "framework/scheduling/statistics.h" +#include "framework/util/Configuration.h" namespace de { -template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L> +template <ShardInterface ShardType, QueryInterface<ShardType> QueryType, + LayoutPolicy L> struct ReconstructionArgs { - Epoch<R, S, Q, L> *epoch; - ReconstructionVector merges; - std::promise<bool> result; - bool compaction; - void *extension; + typedef typename ShardType::RECORD RecordType; + Epoch<ShardType, QueryType, L> *epoch; + ReconstructionVector merges; + std::promise<bool> result; + bool compaction; + void *extension; }; -template <RecordInterface R, ShardInterface<R> S, QueryInterface<R, S> Q, LayoutPolicy L> -struct QueryArgs { - std::promise<std::vector<R>> result_set; - void *query_parms; - void *extension; +template <ShardInterface S, QueryInterface<S> Q, typename DE> struct QueryArgs { + std::promise<std::vector<typename Q::ResultType>> result_set; + typename Q::Parameters query_parms; + DE *extension; }; -typedef std::function<void(void*)> Job; +typedef std::function<void(void *)> Job; struct Task { - Task(size_t size, size_t ts, Job job, void *args, size_t type=0, SchedulerStatistics *stats=nullptr) - : m_job(job) - , m_size(size) - , m_timestamp(ts) - , m_args(args) - , m_type(type) - , m_stats(stats) - {} + Task(size_t size, size_t ts, Job job, void *args, size_t type = 0, + SchedulerStatistics *stats = nullptr) + : m_job(job), m_size(size), m_timestamp(ts), m_args(args), m_type(type), + m_stats(stats) {} - Job m_job; - size_t m_size; - size_t m_timestamp; - void *m_args; - size_t m_type; - SchedulerStatistics *m_stats; + Job m_job; + size_t m_size; + size_t m_timestamp; + void *m_args; + size_t m_type; + SchedulerStatistics *m_stats; - friend bool operator<(const Task &self, const Task &other) { - return self.m_timestamp < other.m_timestamp; - } + friend bool operator<(const Task &self, const Task &other) { + return self.m_timestamp < other.m_timestamp; + } - friend bool operator>(const Task &self, const Task &other) { - return self.m_timestamp > other.m_timestamp; - } + friend bool operator>(const Task &self, const Task &other) { + return self.m_timestamp > other.m_timestamp; + } - void operator()(size_t thrd_id) { - auto start = std::chrono::high_resolution_clock::now(); - if (m_stats) { - m_stats->job_begin(m_timestamp); - } + void operator()(size_t thrd_id) { + auto start = std::chrono::high_resolution_clock::now(); + if (m_stats) { + m_stats->job_begin(m_timestamp); + } - m_job(m_args); + m_job(m_args); - if (m_stats) { - m_stats->job_complete(m_timestamp); - } - auto stop = std::chrono::high_resolution_clock::now(); + if (m_stats) { + m_stats->job_complete(m_timestamp); + } + auto stop = std::chrono::high_resolution_clock::now(); - if (m_stats) { - auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count(); - m_stats->log_time_data(time, m_type); - } + if (m_stats) { + auto time = + std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start) + .count(); + m_stats->log_time_data(time, m_type); } + } }; -} +} // namespace de |