Skip to content

Commit

Permalink
p1: use owned promise for disk scheduler
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <iskyzh@gmail.com>
  • Loading branch information
skyzh committed Sep 11, 2023
1 parent 558030f commit 2861b50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/include/storage/disk/disk_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct DiskRequest {
page_id_t page_id_;

/** Callback used to signal to the request issuer when the request has been completed. */
std::promise<bool> &callback_;
std::promise<bool> callback_;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/storage/disk_scheduler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ TEST(DiskSchedulerTest, DISABLED_ScheduleWriteReadPageTest) {
auto promise2 = disk_scheduler->CreatePromise();
auto future2 = promise2.get_future();

disk_scheduler->Schedule({/*is_write=*/true, reinterpret_cast<char *>(&data), /*page_id=*/0, promise1});
disk_scheduler->Schedule({/*is_write=*/false, reinterpret_cast<char *>(&buf), /*page_id=*/0, promise2});
disk_scheduler->Schedule({/*is_write=*/true, reinterpret_cast<char *>(&data), /*page_id=*/0, std::move(promise1)});
disk_scheduler->Schedule({/*is_write=*/false, reinterpret_cast<char *>(&buf), /*page_id=*/0, std::move(promise2)});

ASSERT_TRUE(future1.get());
ASSERT_TRUE(future2.get());
Expand Down

0 comments on commit 2861b50

Please sign in to comment.