Skip to content

Commit

Permalink
Rename "Low priority" queue to "Normal priority"
Browse files Browse the repository at this point in the history
Mostly for connotation reasons to the user. Tasks in the second
queue are going to be run. High priority tasks will just be run first.
  • Loading branch information
RichieSams committed Jul 1, 2021
1 parent 657357b commit 8ea3477
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main() {
// Schedule the tasks
ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(numTasks, tasks, ftl::TaskPriority::High, &counter);
taskScheduler.AddTasks(numTasks, tasks, ftl::TaskPriority::Normal, &counter);
// FTL creates its own copies of the tasks, so we can safely delete the memory
delete[] tasks;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/empty/empty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ NONIUS_BENCHMARK("Empty", [](nonius::chronometer meter) {
meter.measure([&taskScheduler, tasks] {
for (unsigned i = 0; i < kNumIterations; ++i) {
ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(kNumTasks, tasks, ftl::TaskPriority::Low);
taskScheduler.AddTasks(kNumTasks, tasks, ftl::TaskPriority::Normal);

taskScheduler.WaitForCounter(&counter, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/producer_consumer/producer_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Producer(ftl::TaskScheduler *taskScheduler, void *arg) {
}

ftl::TaskCounter counter(taskScheduler);
taskScheduler->AddTasks(kNumConsumerTasks, tasks, ftl::TaskPriority::Low, &counter);
taskScheduler->AddTasks(kNumConsumerTasks, tasks, ftl::TaskPriority::Normal, &counter);
delete[] tasks;

taskScheduler->WaitForCounter(&counter);
Expand All @@ -63,7 +63,7 @@ NONIUS_BENCHMARK("ProducerConsumer", [](nonius::chronometer meter) {
meter.measure([&taskScheduler, tasks] {
for (unsigned i = 0; i < kNumIterations; ++i) {
ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(kNumProducerTasks, tasks, ftl::TaskPriority::Low);
taskScheduler.AddTasks(kNumProducerTasks, tasks, ftl::TaskPriority::Normal);

taskScheduler.WaitForCounter(&counter);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/triangle_num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main() {

// Schedule the tasks
ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(numTasks, tasks, ftl::TaskPriority::High, &counter);
taskScheduler.AddTasks(numTasks, tasks, ftl::TaskPriority::Normal, &counter);

// FTL creates its own copies of the tasks, so we can safely delete the memory
delete[] tasks;
Expand Down
2 changes: 1 addition & 1 deletion include/ftl/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Task {

enum class TaskPriority {
High,
Low,
Normal,
};

} // End of namespace ftl
4 changes: 2 additions & 2 deletions source/task_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void TaskScheduler::AddTask(Task const task, TaskPriority priority, TaskCounter
const TaskBundle bundle = {task, counter};
if (priority == TaskPriority::High) {
m_tls[GetCurrentThreadIndex()].HiPriTaskQueue.Push(bundle);
} else if (priority == TaskPriority::Low) {
} else if (priority == TaskPriority::Normal) {
m_tls[GetCurrentThreadIndex()].LoPriTaskQueue.Push(bundle);
}

Expand All @@ -449,7 +449,7 @@ void TaskScheduler::AddTasks(unsigned const numTasks, Task const *const tasks, T
WaitFreeQueue<TaskBundle> *queue = nullptr;
if (priority == TaskPriority::High) {
queue = &m_tls[GetCurrentThreadIndex()].HiPriTaskQueue;
} else if (priority == TaskPriority::Low) {
} else if (priority == TaskPriority::Normal) {
queue = &m_tls[GetCurrentThreadIndex()].LoPriTaskQueue;
} else {
FTL_ASSERT("Unknown task priority", false);
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/calc_triangle_num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_CASE("Triangle Number", "[functional]") {

// Schedule the tasks and wait for them to complete
ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(static_cast<unsigned>(numTasks), tasks, ftl::TaskPriority::Low, &counter);
taskScheduler.AddTasks(static_cast<unsigned>(numTasks), tasks, ftl::TaskPriority::Normal, &counter);
delete[] tasks;

taskScheduler.WaitForCounter(&counter);
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/producer_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void Producer(ftl::TaskScheduler *taskScheduler, void *arg) {
}

ftl::TaskCounter counter(taskScheduler);
taskScheduler->AddTasks(kNumConsumerTasks, tasks, ftl::TaskPriority::Low, &counter);
taskScheduler->AddTasks(kNumConsumerTasks, tasks, ftl::TaskPriority::Normal, &counter);
delete[] tasks;

taskScheduler->WaitForCounter(&counter);
Expand All @@ -67,7 +67,7 @@ TEST_CASE("Producer Consumer", "[functional]") {
}

ftl::TaskCounter counter(&taskScheduler);
taskScheduler.AddTasks(kNumProducerTasks, tasks.data(), ftl::TaskPriority::Low, &counter);
taskScheduler.AddTasks(kNumProducerTasks, tasks.data(), ftl::TaskPriority::Normal, &counter);
taskScheduler.WaitForCounter(&counter);

// Test to see that all tasks finished
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/event_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ TEST_CASE("Fiber Event Callbacks", "[utility]") {
};

ftl::TaskCounter waitCounter(&taskScheduler);
taskScheduler.AddTask(testTask, ftl::TaskPriority::Low, &waitCounter);
taskScheduler.AddTask(testTask, ftl::TaskPriority::Normal, &waitCounter);

taskScheduler.WaitForCounter(&waitCounter);

Expand Down
12 changes: 6 additions & 6 deletions tests/utilities/fibtex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ TEST_CASE("Fibtex Locking Tests", "[utility]") {

constexpr size_t iterations = 20000;
for (size_t i = 0; i < iterations; ++i) {
taskScheduler.AddTask(ftl::Task{LockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{LockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{SpinLockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{SpinLockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{InfiniteSpinLockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{InfiniteSpinLockGuardTest, &md}, ftl::TaskPriority::Low, &c);
taskScheduler.AddTask(ftl::Task{LockGuardTest, &md}, ftl::TaskPriority::Normal, &c);
taskScheduler.AddTask(ftl::Task{LockGuardTest, &md}, ftl::TaskPriority::Normal, &c);
taskScheduler.AddTask(ftl::Task{SpinLockGuardTest, &md}, ftl::TaskPriority::Normal, &c);
taskScheduler.AddTask(ftl::Task{SpinLockGuardTest, &md}, ftl::TaskPriority::Normal, &c);
taskScheduler.AddTask(ftl::Task{InfiniteSpinLockGuardTest, &md}, ftl::TaskPriority::Normal, &c);
taskScheduler.AddTask(ftl::Task{InfiniteSpinLockGuardTest, &md}, ftl::TaskPriority::Normal, &c);

taskScheduler.WaitForCounter(&c);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/utilities/thread_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TEST_CASE("Thread Local", "[utility]") {
std::vector<ftl::Task> singleInitTask(taskScheduler.GetThreadCount(), ftl::Task{SimpleInit, &simpleCounter});

ftl::TaskCounter ac(&taskScheduler);
taskScheduler.AddTasks(static_cast<unsigned>(singleInitTask.size()), singleInitTask.data(), ftl::TaskPriority::Low, &ac);
taskScheduler.AddTasks(static_cast<unsigned>(singleInitTask.size()), singleInitTask.data(), ftl::TaskPriority::Normal, &ac);
taskScheduler.WaitForCounter(&ac);

auto singleInitVals = simpleCounter.GetAllValues();
Expand All @@ -73,7 +73,7 @@ TEST_CASE("Thread Local", "[utility]") {

std::vector<ftl::Task> sideEffectTask(10000, ftl::Task{SideEffect, &sideEffectCounter});

taskScheduler.AddTasks(static_cast<unsigned>(sideEffectTask.size()), sideEffectTask.data(), ftl::TaskPriority::Low, &ac);
taskScheduler.AddTasks(static_cast<unsigned>(sideEffectTask.size()), sideEffectTask.data(), ftl::TaskPriority::Normal, &ac);
taskScheduler.WaitForCounter(&ac);

auto sideEffect = sideEffectCounter.GetAllValues();
Expand Down

0 comments on commit 8ea3477

Please sign in to comment.