Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/tev/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ template <typename F> void forEachFileInDir(bool recursive, const fs::path& path
template <std::invocable F> class ScopeGuard {
public:
ScopeGuard(const F& callback) : mCallback{callback} {}
ScopeGuard(F&& callback) : mCallback{std::move(callback)} {}
ScopeGuard(F&& callback) : mCallback{std::forward<F>(callback)} {}
ScopeGuard(const ScopeGuard<F>& other) = delete;
ScopeGuard& operator=(const ScopeGuard<F>& other) = delete;
ScopeGuard(ScopeGuard<F>&& other) { *this = std::move(other); }
Expand Down
4 changes: 2 additions & 2 deletions include/tev/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ template <typename F> concept TaskCoroutine = std::invocable<F> && is_task<std::

template <TaskCoroutine F, typename... Args> Task<void> invokeTask(F&& executor, Args&&... args) {
auto exec = std::forward<F>(executor);
co_await exec(args...);
co_await exec(std::forward<Args>(args)...);
}

template <TaskCoroutine F, typename... Args> DetachedTask invokeTaskDetached(F&& executor, Args&&... args) {
auto exec = std::forward<F>(executor);
co_await exec(args...);
co_await exec(std::forward<Args>(args)...);
}

void waitAll(range_of<Task<void>> auto&& futures) {
Expand Down
13 changes: 7 additions & 6 deletions include/tev/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ThreadPool {
}

template <std::integral Int, std::invocable<Int, Int> F>
Task<void> parallelFor(Int start, Int end, size_t approxCost, F body, int priority) {
Task<void> parallelFor(Int start, Int end, size_t approxCost, F&& body, int priority) {
const Int range = end - start;
const Int n = nTasks(start, end, approxCost);

Expand Down Expand Up @@ -190,7 +190,7 @@ class ThreadPool {
}

template <std::integral Int, std::invocable<Int> F>
Task<void> parallelFor(Int start, Int end, size_t approxCost, F body, int priority) {
Task<void> parallelFor(Int start, Int end, size_t approxCost, F&& body, int priority) {
co_await parallelFor(
start,
end,
Expand All @@ -211,12 +211,13 @@ class ThreadPool {
}

template <std::integral Int, std::invocable<Int, Int> F>
void parallelForSync(Int start, Int end, size_t approxCost, F body, int priority) {
blockAndDrain(parallelFor(start, end, approxCost, body, priority));
void parallelForSync(Int start, Int end, size_t approxCost, F&& body, int priority) {
blockAndDrain(parallelFor(start, end, approxCost, std::forward<F>(body), priority));
}

template <std::integral Int, std::invocable<Int> F> void parallelForSync(Int start, Int end, size_t approxCost, F body, int priority) {
blockAndDrain(parallelFor(start, end, approxCost, body, priority));
template <std::integral Int, std::invocable<Int> F>
void parallelForSync(Int start, Int end, size_t approxCost, F&& body, int priority) {
blockAndDrain(parallelFor(start, end, approxCost, std::forward<F>(body), priority));
}

size_t numThreads() const { return mNumThreads; }
Expand Down
Loading