Fix compilation errors.
This commit is contained in:
parent
71a8abb92d
commit
e7406475ff
@ -20,6 +20,7 @@
|
|||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/ObjectPool.h"
|
#include "td/utils/ObjectPool.h"
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
|
#include "td/utils/Span.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
#include "td/utils/Container.h"
|
#include "td/utils/Container.h"
|
||||||
#include "td/utils/List.h"
|
#include "td/utils/List.h"
|
||||||
#include "td/utils/optional.h"
|
#include "td/utils/optional.h"
|
||||||
#include "td/utils/Span.h"
|
|
||||||
#include "td/utils/tests.h"
|
|
||||||
#include "td/utils/VectorQueue.h"
|
|
||||||
#include "td/utils/Random.h"
|
#include "td/utils/Random.h"
|
||||||
|
#include "td/utils/Span.h"
|
||||||
|
#include "td/utils/VectorQueue.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -16,6 +15,11 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
struct ChainSchedulerTaskWithParents {
|
||||||
|
uint64 task_id{};
|
||||||
|
vector<uint64> parents;
|
||||||
|
};
|
||||||
|
|
||||||
template <class ExtraT = Unit>
|
template <class ExtraT = Unit>
|
||||||
class ChainScheduler {
|
class ChainScheduler {
|
||||||
public:
|
public:
|
||||||
@ -24,16 +28,11 @@ class ChainScheduler {
|
|||||||
TaskId create_task(td::Span<ChainId> chains, ExtraT extra = {});
|
TaskId create_task(td::Span<ChainId> chains, ExtraT extra = {});
|
||||||
ExtraT *get_task_extra(TaskId task_id);
|
ExtraT *get_task_extra(TaskId task_id);
|
||||||
|
|
||||||
struct TaskWithParents {
|
optional<ChainSchedulerTaskWithParents> start_next_task();
|
||||||
TaskId task_id{};
|
|
||||||
std::vector<TaskId> parents;
|
|
||||||
};
|
|
||||||
|
|
||||||
optional<TaskWithParents> start_next_task();
|
|
||||||
void finish_task(TaskId task_id);
|
void finish_task(TaskId task_id);
|
||||||
void reset_task(TaskId task_id);
|
void reset_task(TaskId task_id);
|
||||||
template <class ExtraTT>
|
template <class ExtraTT>
|
||||||
friend td::StringBuilder &operator<<(StringBuilder &sb, ChainScheduler<ExtraTT> &scheduler);
|
friend StringBuilder &operator<<(StringBuilder &sb, ChainScheduler<ExtraTT> &scheduler);
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
void for_each(F &&f) {
|
void for_each(F &&f) {
|
||||||
@ -226,12 +225,12 @@ ExtraT *ChainScheduler<ExtraT>::get_task_extra(ChainScheduler::TaskId task_id) {
|
|||||||
return &task->extra;
|
return &task->extra;
|
||||||
}
|
}
|
||||||
template <class ExtraT>
|
template <class ExtraT>
|
||||||
optional<typename ChainScheduler<ExtraT>::TaskWithParents> ChainScheduler<ExtraT>::start_next_task() {
|
optional<ChainSchedulerTaskWithParents> ChainScheduler<ExtraT>::start_next_task() {
|
||||||
if (pending_tasks_.empty()) {
|
if (pending_tasks_.empty()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto task_id = pending_tasks_.pop();
|
auto task_id = pending_tasks_.pop();
|
||||||
TaskWithParents res;
|
ChainSchedulerTaskWithParents res;
|
||||||
res.task_id = task_id;
|
res.task_id = task_id;
|
||||||
auto *task = tasks_.get(task_id);
|
auto *task = tasks_.get(task_id);
|
||||||
CHECK(task);
|
CHECK(task);
|
||||||
@ -271,7 +270,7 @@ void ChainScheduler<ExtraT>::reset_task(ChainScheduler::TaskId task_id) {
|
|||||||
try_start_task(task_id, task);
|
try_start_task(task_id, task);
|
||||||
}
|
}
|
||||||
template <class ExtraT>
|
template <class ExtraT>
|
||||||
td::StringBuilder &operator<<(StringBuilder &sb, ChainScheduler<ExtraT> &scheduler) {
|
StringBuilder &operator<<(StringBuilder &sb, ChainScheduler<ExtraT> &scheduler) {
|
||||||
// 1 print chains
|
// 1 print chains
|
||||||
sb << "\n";
|
sb << "\n";
|
||||||
for (auto &it : scheduler.chains_) {
|
for (auto &it : scheduler.chains_) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "td/utils/algorithm.h"
|
#include "td/utils/algorithm.h"
|
||||||
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/optional.h"
|
#include "td/utils/optional.h"
|
||||||
#include "td/utils/Span.h"
|
#include "td/utils/Span.h"
|
||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
@ -90,7 +91,7 @@ TEST(ChainScheduler, Stress) {
|
|||||||
td::random_shuffle(td::as_mutable_span(chain_ids), rnd);
|
td::random_shuffle(td::as_mutable_span(chain_ids), rnd);
|
||||||
chain_ids.resize(chain_n);
|
chain_ids.resize(chain_n);
|
||||||
for (auto chain_id : chain_ids) {
|
for (auto chain_id : chain_ids) {
|
||||||
chains[chain_id].push_back(query);
|
chains[td::narrow_cast<size_t>(chain_id)].push_back(query);
|
||||||
}
|
}
|
||||||
auto task_id = scheduler.create_task(chain_ids, query);
|
auto task_id = scheduler.create_task(chain_ids, query);
|
||||||
query->task_id = task_id;
|
query->task_id = task_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user