Commit aa0ba075 authored by Philip Pronin's avatar Philip Pronin Committed by Facebook GitHub Bot

expose multi-add in SoftRealTimeExecutor

Summary:
`EDFThreadPoolExecutor` is currently the only implementation of
`SoftRealTimeExecutor`, and it implements multi-add functionality (which
allows us to wake up idle threads just once on batch-add, as well as reduces
planning overhead), let's expose this at an interface level.

Reviewed By: ot, luciang

Differential Revision: D34095644

fbshipit-source-id: ba59300a4c51599d7c6cbfaaabe3d6013be7c37f
parent d14c1d91
......@@ -255,10 +255,6 @@ void EDFThreadPoolExecutor::add(Func f) {
add(std::move(f), kLatestDeadline);
}
void EDFThreadPoolExecutor::add(Func f, uint64_t deadline) {
add(std::move(f), 1, deadline);
}
void EDFThreadPoolExecutor::add(Func f, std::size_t total, uint64_t deadline) {
if (UNLIKELY(isJoin_.load(std::memory_order_relaxed) || total == 0)) {
return;
......
......@@ -48,12 +48,12 @@ class EDFThreadPoolExecutor : public SoftRealTimeExecutor,
~EDFThreadPoolExecutor() override;
using SoftRealTimeExecutor::add;
using ThreadPoolExecutor::add;
void add(Func f) override;
void add(Func f, uint64_t deadline) override;
void add(Func f, std::size_t total, uint64_t deadline);
void add(std::vector<Func> fs, uint64_t deadline);
void add(Func f, std::size_t total, uint64_t deadline) override;
void add(std::vector<Func> fs, uint64_t deadline) override;
folly::Executor::KeepAlive<> deadlineExecutor(uint64_t deadline);
......
......@@ -16,6 +16,10 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <vector>
#include <folly/Executor.h>
namespace folly {
......@@ -33,10 +37,15 @@ class SoftRealTimeExecutor : public virtual Executor {
// a typed time point or duration (e.g., `std::chrono::time_point`) to allow
// for flexibility. While the deadline for a task may be a time point,
// it could also be a duration or the size of the task, which emulates
// rate-monotonic scheduling that prioritizes small tasks. It also enables
// rate-monotonic scheduling that prioritizes small tasks. It also enables,
// for example, tiered scheduling (strictly prioritizing a category of tasks)
// by assigning the high-bit of the deadline.
virtual void add(Func, uint64_t deadline) = 0;
void add(Func func, uint64_t deadline) {
add(std::move(func), /* total */ 1, deadline);
}
virtual void add(Func, std::size_t total, uint64_t deadline) = 0;
virtual void add(std::vector<Func>, uint64_t deadline) = 0;
};
} // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment