Skip to content

Commit

Permalink
refactor: select to take a tasks vector reference (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Jun 21, 2024
1 parent 827a10d commit 2d7031a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions host-apis/wasi-0.2.0-rc-2023-10-18/host_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ template <> struct HandleOps<Pollable> {

} // namespace

size_t api::AsyncTask::select(std::vector<api::AsyncTask *> *tasks) {
auto count = tasks->size();
size_t api::AsyncTask::select(std::vector<api::AsyncTask *> &tasks) {
auto count = tasks.size();
vector<Borrow<Pollable>> handles;
for (const auto task : *tasks) {
for (const auto task : tasks) {
handles.emplace_back(task->id());
}
auto list = list_borrow_pollable_t{
Expand Down
6 changes: 3 additions & 3 deletions host-apis/wasi-0.2.0-rc-2023-12-05/host_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ template <> struct HandleOps<Pollable> {

} // namespace

size_t api::AsyncTask::select(std::vector<api::AsyncTask *> *tasks) {
auto count = tasks->size();
size_t api::AsyncTask::select(std::vector<api::AsyncTask *> &tasks) {
auto count = tasks.size();
vector<Borrow<Pollable>> handles;
for (const auto task : *tasks) {
for (const auto task : tasks) {
handles.emplace_back(task->id());
}
auto list = list_borrow_pollable_t{
Expand Down
6 changes: 3 additions & 3 deletions host-apis/wasi-0.2.0/host_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ class OutgoingBodyHandle final : public WASIHandle<host_api::HttpOutgoingBody> {
}
};

size_t api::AsyncTask::select(std::vector<AsyncTask *> *tasks) {
auto count = tasks->size();
size_t api::AsyncTask::select(std::vector<AsyncTask *> &tasks) {
auto count = tasks.size();
vector<WASIHandle<host_api::Pollable>::Borrowed> handles;
for (const auto task : *tasks) {
for (const auto task : tasks) {
handles.emplace_back(task->id());
}
auto list = list_borrow_pollable_t{ handles.data(), count};
Expand Down
2 changes: 1 addition & 1 deletion include/extension-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AsyncTask {
/**
* Select for the next available ready task, providing the oldest ready first.
*/
static size_t select(std::vector<AsyncTask *> *handles);
static size_t select(std::vector<AsyncTask *> &handles);
};

} // namespace api
Expand Down
2 changes: 1 addition & 1 deletion runtime/event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool EventLoop::run_event_loop(api::Engine *engine, double total_compute) {
}

// Select the next task to run according to event-loop semantics of oldest-first.
size_t task_idx = api::AsyncTask::select(tasks);
size_t task_idx = api::AsyncTask::select(*tasks);

auto task = tasks->at(task_idx);
bool success = task->run(engine);
Expand Down

0 comments on commit 2d7031a

Please sign in to comment.